我目前正在开发一个使用 Angular-leaflet-directive + leaflet markcluster 插件的项目。
我想要做的是,在某个事件(例如,+/- 缩放级别或聚类组更改时)我希望运行一个函数来返回当前未聚类的所有标记。
这样做的原因是因为我想让所有可见标记周围都有一个圆形路径(20海里,但这并不重要)..
有人知道这是否可能吗?
感谢您的帮助。请告诉我您可能需要哪些其他信息,我会尽力为您提供。
干杯!
最佳答案
创建 markerClusterGroup
后,您可以执行以下操作:
// Let's assume you have a global map variable that refers to the Leaflet Map
MyClusterGroup.eachLayer(function(feature) {
// the cluster group holds all the features
// but only the ones not clustered are added to the map
if (map.hasLayer(feature)) {
feature.setStyle({ // Only feature not clustered will have their style re-render
fillColor : "red"
});
// Do whatever your want with this feature, you have full access to it
}
});
就性能而言,这可能不是最好的方法,但我想这对于您的情况来说效果很好。否则,您应该潜入标记插件代码并直接修改/扩展它以满足您的需求。
关于javascript - 有没有办法返回当前不在聚类组内的所有标记的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32793019/