2

I have a feature layer and some pins on it, with mouseout, mouseover events callbacks on the feature. When the mouse is over the pin icon, that triggers mouseout event (mouseout from the feature layer). I am trying to stop event propagation but nothing works.

How can the leaflet event propagation be stopped?

None of those worked:

DomEvent.stopPropagation(e);
DomEvent.preventDefault(e);
DomEvent.stop(e);
stopPropagation(e.originalEvent);
preventDefault(e.originalEvent);
stop(e.originalEvent); 
2
0

Okay, finally got it figured out on stopping the propagation of events. e.g.

someReference.on("click", (evt: L.LeafletEvent) => {
    // You don't try to reference the event (evt) that is passed in

    L.DomEvent.preventDefault(evt); // Just call this
    ...
})
0

If you're interested in stopping propagation for a Marker, you can just set bubblingMouseEvents to false in the options: https://leafletjs.com/reference-1.6.0.html#marker-bubblingmouseevents

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.