Customize clustering of markers on Leaflet maps

别来无恙 提交于 2021-01-03 08:46:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!