Czy ktoś miał podobny problem, chce aby po kliknięciu w button moje clustry na mapie zamieniły się w same markery, po drugim kliknięciu znowu wróciły do postaci clustrów.
W projekcie używam biblioteki Leaflet. Plugin markercluster pozwala tworzyć clustry. Posiada dwie metody spiderfy i unspiderfy. Nie wiem dokładnie jak je użyć do usuniecia clustra i pokazania markerów i na odwrót.
Cluster tworze w taki sposób:
const clus = new L.markerClusterGroup({
spiderfyOnMaxZoom: this.$scope.options.clusterZoom,
zoomToBoundsOnClick: true
})
var mapMarkers = markers.map(marker => {
let newMarker = this.createMarker(marker)
if (newMarker) {
let mapMarker = newMarker
this.markers[marker.referenceValue] = mapMarker
clus.addLayer(mapMarker)
return mapMarker
}
})
if (this.$scope.options.isClustering) {
this.mapCluster = this.map.addLayer(clus)
}