Leaflet-search custom result marker

270 views Asked by At

I use leaflet search control and i hide all the points in geojson layer(i set them to transparent and i reduce marker size). Then in leaflet-search.js i add custom marker to put on the map when location is found : Line 89( https://github.com/stefanocudini/leaflet-search/blob/master/src/leaflet-search.js )

marker: {
    icon: L.AwesomeMarkers.icon({
        icon: 'fas fa-sign-in-alt',
        prefix: 'fa',
        markerColor: 'orange'
    })

}

Is there a way to bind popup to marker that is put on the map by leaflet-search.js?

1

There are 1 answers

0
hamzarh On

This is how you bind a popup to marker with Leaflet

    //create marker with popup
    var myMarker = L.marker([51.5, -0.09], {
        icon: L.AwesomeMarkers.icon({
            icon: 'fas fa-sign-in-alt',
            markerColor: 'orange',
            prefix: 'fa'
        }),
        draggable: false
    }).bindPopup("text");

    //attribute the new marker
    marker: myMarker 

If you need to do it otherwise please provide your full code