1

I have a custom div (with settings) within a map. I would like click event not to propagate to map when a user clicks on the div. How could one achieve such behavior?

Leaflet version 1.0.

makar
  • 155
  • 3
  • 14

2 Answers2

3

See the documentation for L.DomEvent.stopPropagation().

IvanSanchez
  • 18,272
  • 3
  • 30
  • 45
  • 1
    And `L.DomEvent.disableClickPropagation(myDiv)` if you want to disable all click-related events for a div. – Toast Sep 03 '19 at 02:12
2

For anyone else coming here from a search engine, if you are trying to prevent clicks from a circle or other interactive layer from being handled by the underlying object (other circle or the map itself) you could also create the layer passing the option bubblingMouseEvents: false

Documentation: http://leafletjs.com/reference-1.2.0.html#interactive-layer

carlosrafaelgn
  • 831
  • 1
  • 16
  • 19