我設立一個以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