Leaflet map.on(click) event isn't triggered on the marker which has its own onclick event

Viewed 432

I have a marker which has its own onclick event

marker.on("click", function(e){ 
        let popup = e.target.getPopup();
        .... // fill with content when clicked

and a map event

map.on("click",function(e){
  console.log(e.latlng);
}

Clicking where the marker is placed triggers only the marker event (popup's being opened). Is there any possibility to trigger both events?

1 Answers

Set

bubblingMouseEvents: true

in marker options. Then a mouse event on this marker will trigger the same event on the map (unless L.DomEvent.stopPropagation is used).

Related