Display a Popup
Add a popup to the map.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.smartmaps.cloud/packages/smartmaps/smartmaps-gl/v2/umd/smartmaps-gl.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
html,
body,
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
// Initialize the map
const map = new smartmapsgl.Map({
apiKey: "INSERT API-KEY",
container: "map",
center: { lat: 49.02164948779226, lng: 8.439330018049352 },
zoom: 3,
style: smartmapsgl.MapStyle.AUTO
});
// Add a popup to the map
const popup = new smartmapsgl.Popup()
.setLngLat({ lat: 49.02164948779226, lng: 8.439330018049352 })
.setHTML("<h1>Hello World!</h1>")
.addTo(map);
</script>
</body>
</html>