Clear inactive clusters on view switch
All checks were successful
Build Docker Image / build (push) Successful in 4m27s
All checks were successful
Build Docker Image / build (push) Successful in 4m27s
This commit is contained in:
@@ -800,12 +800,11 @@ const initServerClusteringLayersByType = async (map: MapboxMapType) => {
|
|||||||
const features = map.queryRenderedFeatures(e.point, { layers: [clusterLayerId] })
|
const features = map.queryRenderedFeatures(e.point, { layers: [clusterLayerId] })
|
||||||
const feature = features[0]
|
const feature = features[0]
|
||||||
if (!feature) return
|
if (!feature) return
|
||||||
const clusterId = feature.properties?.cluster_id
|
const expansionZoom = feature.properties?.expansionZoom
|
||||||
const source = map.getSource(sourceIdByType) as mapboxgl.GeoJSONSource
|
const geometry = feature.geometry as GeoJSON.Point
|
||||||
source.getClusterExpansionZoom(clusterId, (err, zoom) => {
|
map.easeTo({
|
||||||
if (err) return
|
center: geometry.coordinates as [number, number],
|
||||||
const geometry = feature.geometry as GeoJSON.Point
|
zoom: expansionZoom || map.getZoom() + 2
|
||||||
map.easeTo({ center: geometry.coordinates as [number, number], zoom: zoom || 4 })
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -316,8 +316,15 @@ const clusterLoading = computed(() => {
|
|||||||
return offerClusters.loading.value
|
return offerClusters.loading.value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const clearInactiveClusters = (active: 'offer' | 'hub' | 'supplier') => {
|
||||||
|
if (active !== 'offer') offerClusters.clearNodes()
|
||||||
|
if (active !== 'hub') hubClusters.clearNodes()
|
||||||
|
if (active !== 'supplier') supplierClusters.clearNodes()
|
||||||
|
}
|
||||||
|
|
||||||
const fetchActiveClusters = async () => {
|
const fetchActiveClusters = async () => {
|
||||||
if (!currentBounds.value) return
|
if (!currentBounds.value) return
|
||||||
|
clearInactiveClusters(activeClusterType.value)
|
||||||
if (activeClusterType.value === 'hub') {
|
if (activeClusterType.value === 'hub') {
|
||||||
await hubClusters.fetchClusters(currentBounds.value)
|
await hubClusters.fetchClusters(currentBounds.value)
|
||||||
return
|
return
|
||||||
@@ -333,6 +340,7 @@ const fetchActiveClusters = async () => {
|
|||||||
watch(mapViewMode, async () => {
|
watch(mapViewMode, async () => {
|
||||||
if (!props.useServerClustering) return
|
if (!props.useServerClustering) return
|
||||||
if (useTypedClusters.value) {
|
if (useTypedClusters.value) {
|
||||||
|
clearInactiveClusters(activeClusterType.value)
|
||||||
if (currentBounds.value) {
|
if (currentBounds.value) {
|
||||||
await fetchActiveClusters()
|
await fetchActiveClusters()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user