我设立一个以GeoJSON层,并在其顶部的MarkerCluster层刷新标记集群已经改变
this.itemLayer = L.geoJson(items, layerOptions)
this.clusterLayer = L.markerClusterGroup()
this.clusterLayer.addLayer(this.itemLayer)
this.clusterLayer.addTo(this.map)
在更新我做:
this.itemLayer.clearLayers()
this.itemLayer.addData(newItems)
this.clusterLayer.refreshClusters(this.itemLayer)
但集群做没有出现,也没有在itemLayer
解决方案做的项目
this.itemLayer.clearLayers()
this.itemLayer.addData(this.props.items)
this.clusterLayer.clearLayers()
this.clusterLayer.addLayer(this.itemLayer)
谢谢,我会在本周晚些时候进行测试。 – philk
'this.itemLayer.clearLayers() this.itemLayer.addData(this.props.items) this.clusterLayer.clearLayers() this.clusterLayer.addLayer(this.itemLayer) ' 似乎工作。它看起来对你正确吗@ghybs – philk
对我来说很好看:-) – ghybs