本文介绍了自定义传单地图上标记的聚类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发带有大量标记的应用程序,并且希望将它们聚类.我找到了Leaflet.markercluster,它做得很好.但是,我想自定义标记的聚类.具体来说,我想根据标记所在的国家/地区对标记进行聚类.我不希望包含欧洲所有标记的聚类,而是按国家/地区分类几个聚类.
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);
这篇关于自定义传单地图上标记的聚类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!