Leaflet:自动将集群的颜色/或 spiderfy 更改为集群中选定的标记。

Leaflet: auto change color of cluster / or spiderfy to chosen marker in cluster.

我目前正在 Leaftlet Marker Cluster 上练习。

1。 如果我知道我需要的标记在一个集群下,我如何在不点击集群的情况下自动将该集群蜘蛛化到获得我需要的标记的最大缩放级别?

2。 如果我知道该簇中的标记,我如何自动更改该簇的颜色以便我知道我需要查找的标记在该簇下。

  1. Down the page 在你上面列出的 github 回购中,我发现这个方法可能会回答你的第一个问题:
  • zoomToShowLayer(layer, callback): Zooms to show the given marker (spiderfying if required), calls the callback when the marker is visible on the map.
  1. 看起来 these methods 可用于根据该集群中的单个标记更新单个集群的样式:

If you have customized the clusters icon to use some data from the contained markers, and later that data changes, use this method to force a refresh of the cluster icons. You can use the method: ...

  • with a single marker.

具体来说:

// If updating only one marker, pass true to
// refresh this marker's parent clusters right away.
myMarker.refreshIconOptions(optionsMap, true);