简体   繁体   中英

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.

您只需zoomToBoundsOnClick L.markerClusterGroup()zoomToBoundsOnClick -option设置为false: http : //jsfiddle.net/LzUkF/29/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM