问题
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?
回答1:
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);
来源:https://stackoverflow.com/questions/35607840/customize-clustering-of-markers-on-leaflet-maps