Skip to main content
improved answer based on comments
Source Link
toms
  • 7.1k
  • 1
  • 26
  • 31

Your events are propagating to the map. Leaflet provides DomEvent methods to prevent this, for example (using jQuery):

$('div').each(function () {
    L.DomEvent.on(this,'mousedown',L.DomEvent.stop);
    L.DomEvent.on(this,'click',L.DomEvent.stop);
    L.DomEvent.on(this,'touchstart',L.DomEvent.stop);
});

UDPATE

Based on comments below, the following should also work in place of the code above:

L.DomEvent.disableClickPropagation();

Reference: http://leafletjs.com/reference.html#domevent-disableclickpropagation

Your events are propagating to the map. Leaflet provides DomEvent methods to prevent this, for example (using jQuery):

$('div').each(function () {
    L.DomEvent.on(this,'mousedown',L.DomEvent.stop);
    L.DomEvent.on(this,'click',L.DomEvent.stop);
    L.DomEvent.on(this,'touchstart',L.DomEvent.stop);
});

Your events are propagating to the map. Leaflet provides DomEvent methods to prevent this, for example (using jQuery):

$('div').each(function () {
    L.DomEvent.on(this,'mousedown',L.DomEvent.stop);
    L.DomEvent.on(this,'click',L.DomEvent.stop);
    L.DomEvent.on(this,'touchstart',L.DomEvent.stop);
});

UDPATE

Based on comments below, the following should also work in place of the code above:

L.DomEvent.disableClickPropagation();

Reference: http://leafletjs.com/reference.html#domevent-disableclickpropagation

Source Link
toms
  • 7.1k
  • 1
  • 26
  • 31

Your events are propagating to the map. Leaflet provides DomEvent methods to prevent this, for example (using jQuery):

$('div').each(function () {
    L.DomEvent.on(this,'mousedown',L.DomEvent.stop);
    L.DomEvent.on(this,'click',L.DomEvent.stop);
    L.DomEvent.on(this,'touchstart',L.DomEvent.stop);
});