javascript - Stop propagation of 'click' event in Leaflet -


in 1 of our projects we're using leaflet along leaflet.markercluster plugin. looking through leaflet's sources found appends _collapse() function map's click event, whenever click on map contracts expanded cluster.
now, want disable behavior. if cluster expanded, want deselect of markers on click event (and don't contract cluster itself). here piece of code:

map.on('click', function(e) {     scope.deselectallmarkers(); }); 

i tried add following lines in end of one-line callback in order stop propagation of click event:

scope.l.domevent.stoppropagation(e);
scope.l.domevent.preventdefault(e);
scope.l.domevent.stop(e);
scope.l.domevent.stoppropagation(e.originalevent);
scope.l.domevent.preventdefault(e.originalevent);
scope.l.domevent.stop(e.originalevent);

and none of them works. default listener hidden inside of leaflet sources keeps invocation whenever click on map. missing something?

i know answer quite late, if interested in solution, here how have solved it.

this snippet here below example of binding function click event.

map.on('click', dosomething); 

actually, after checking leaflet's api , geekish debugging, seems event returns object, not event itself. event wrapped field within returned object.

var dosomething = function(map) {     // stop propagation     map.originalevent.preventdefault(); }; 

when using above snippet, event bubbling has stopped, wanted, , wanted.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -