stefanocudini / leaflet-search

Search stuff in a Leaflet map
https://opengeo.tech/maps/leaflet-search/
MIT License
772 stars 334 forks source link

Fire click event #298

Closed jeffjb4488 closed 11 months ago

jeffjb4488 commented 2 years ago

Is there a way to fire a click event when search location is found? I would like to have a popup opened when the location searched for is clicked, but since i am using leaflet Point in Polygon and generating my popups through "zoomToFeatures" function, which is called when the map is clicked on, the normal function of the leaflet-search code to open popups does not work.

Here is my github repo: https://github.com/jeffjb4488/GeoJASON_test

Thank you very much, Jeff

ericek111 commented 2 years ago
const searchControl = new L.Control.Search({
    ...
    moveToLocation: (latlng, title, map) => {
        latlng.layer.fire('click');
    }
})