I'm working on an app with a large number of markers and would like to cluster them. I found Leaflet.markercluster and it does a good job. However, I would like to customize the clustering of the markers. Specifically, I want to cluster my markers depending on the country they are in. I don't want a cluster which includes all markers in Europe but instead several clusters by country.
Is there any way to achieve this?
You can create several clusters and add your markers to them accordingly.
var franceCluster = L.markerClusterGroup();
var germanyCluster = L.markerClusterGroup();
franceCluster.addLayer(parisMarker);
germanyCluster.addLayer(berlinMarker);
map.addLayer(franceCluster);
map.addLayer(germanyCluster);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With