Features

Add popup on click

                        
        <!DOCTYPE html>
        <html lang="en">
        <head>
            <title>Vector map</title>
            <meta property="og:description" content="Display vector tile." />
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@4.4.0/dist/maplibre-gl.css" />
            <script src="https://unpkg.com/maplibre-gl@4.4.0/dist/maplibre-gl.js"></script>
            <style>
                #map{
                    height:400px;
                }
                #marker {
                    background-image: url('/images/features/blue-marker.svg');
                    background-size: cover;
                    width: 30px;
                    height: 50px;
                    cursor: pointer;
                }

                .maplibregl-popup {
                    max-width: 200px;
                }
            </style>
        </head>
        <body>
            <div id="map"></div>

            <script>
                const coordinates = [6.22769, 46.39282];
                map = new maplibregl.Map({
                    "container": "map",
                    "center": coordinates,
                    "zoom": 10,
                    "style": 'https://www.iso-maps.com/map/style/standard.json?api_key=YOUR_API_KEY'
                });

                map.addControl(new maplibregl.FullscreenControl());

                map.addControl(new maplibregl.NavigationControl({
                    visualizePitch: true,
                    showZoom: true,
                    showCompass: true
                }));

                // create the popup
                const popup = new maplibregl.Popup({offset: 25}).setHTML(
                    '<p style="color=#000;"><b>IsoMaps Geoservices</b><br />Chemin des Cottages 19<br />1260 Nyon</p>'
                );

                // create DOM element for the marker
                const el = document.createElement('div');
                el.id = 'marker';

                // create the marker
                new maplibregl.Marker({element: el})
                    .setLngLat(coordinates)
                    .setPopup(popup) // sets a popup on this marker
                    .addTo(map);


            </script>
        </body>
        </html>

                            

Ready to Transform Your
Mapping Experience
with IsoMaps?

Sign up for free
No credit card required

Questions? Our support team is ready for you