Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leaflet JS Cluster Marker cancel click event

I've been struggling to cancel the click event that occurs when clicking on a cluster in leaflet. So when I click on a clustered pin the map zooms in. I'd like a custom popup to appear or at least have some way of making sure the map doesn't zoom in when I click on the clustered pin.

I've tried various tricks that I remember such as

layerMakers.on('clusterclick', function(e) {
    e.originalEvent.preventDefault();
    e.originalEvent.stopPropagation();

    L.DomEvent.stopPropagation(e);
    return false;
});

Here is a fiddle demonstrating the problem. Note I've left out all my attempts from this just to make it easier to play with.

http://jsfiddle.net/LzUkF/28/

Any answers gratefully received.

like image 900
Captain John Avatar asked Dec 27 '13 17:12

Captain John


1 Answers

You only need to set the zoomToBoundsOnClick-option of the L.markerClusterGroup() to false: http://jsfiddle.net/LzUkF/29/

like image 59
Dr.Molle Avatar answered Oct 18 '22 17:10

Dr.Molle