Closed mapsam closed 9 years ago
so markerCluster seems to not have included a new update that spiderfys if the zoom is unecessary. There's a nice pull request in the markercluster repo that makes sure zoom is necessary and if it isn't spiderfy occurs. https://github.com/Leaflet/Leaflet.markercluster/pull/415
This needs to be updated in the source code for markercluster since it's not in their distribution version yet.
Here's the code to replace the _zoomOrSpiderfy
function with:
_zoomOrSpiderfy: function (e) {
var map = this._map;
if (e.layer._bounds._northEast.equals(e.layer._bounds._southWest)){
if (this.options.spiderfyOnMaxZoom) {
e.layer.spiderfy();
}
} else if (map.getMaxZoom() === map.getZoom()) {
if (this.options.spiderfyOnMaxZoom) {
e.layer.spiderfy();
}
} else if (this.options.zoomToBoundsOnClick) {
e.layer.zoomToBounds();
}
// Focus the map again for keyboard users.
if (e.originalEvent && e.originalEvent.keyCode === 13) {
map._container.focus();
}
},
right now there are some unnecessary zoom events with L.markerCluster() that can be fixed by maxZoom