Med Lemark
Med Lemark

Reputation: 21

leaflet popup when user click ouside the geojson features

i have made leafletjs map,i need help to set popup for :

1-geojson data ( this i have done with

L.geoJson(data,{style:first}).on('click',makePopup).addTo(map); )

2-when user click outside the blue area show another popup see screenshot when user click on the non blue area how can i make popup

Upvotes: 2

Views: 971

Answers (1)

YaFred
YaFred

Reputation: 10008

You have to listen to the click events on the map.

    var popup = L.popup();

    function onMapClick(e) {
        popup
            .setLatLng(e.latlng)
            .setContent("You clicked the map at " + e.latlng.toString())
            .openOn(mymap);
    }

    mymap.on('click', onMapClick);

Upvotes: 1

Related Questions