Spiderfy markers on same position with Leaflet.markercluster

Considering a map set as:

map = new L.Map( map_id, {
	minZoom: 10,
	maxZoom: 18,
});

Set cluster group, disabling clustering after maxZoom, so spiderfy will be still on:

clusterGroup = L.markerClusterGroup({
	disableClusteringAtZoom: map.options.maxZoom + 1,
});

Set listener:

clusterGroup.on( 'clusterclick', function ( a ) {
	if ( map.options.maxZoom == a.layer._zoom ) {
		a.layer.spiderfy();
	}
});

So, if you are at maximum zoom and markers are still clustered, it spiderfies on click.

References

StackOverflow, Limit Zoom level when markers are on the same position

Advertisements