diff --git a/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue b/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue index d4ac0ccb..438d15d6 100644 --- a/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +++ b/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue @@ -62,7 +62,9 @@ whenever(() => mapContext?.map.value && mapContext.mapsApi.value, () => { setupMarkerEventListeners(marker.value) if (markerClustererContext?.markerClusterer.value) { - markerClustererContext.markerClusterer.value.addMarker(marker.value) + markerClustererContext.markerClusterer.value.addMarker(marker.value, true) + + markerClustererContext.requestRerender() } else { marker.value.setMap(mapContext!.map.value!) @@ -88,7 +90,7 @@ onUnmounted(() => { if (markerClustererContext?.markerClusterer.value) { markerClustererContext.markerClusterer.value.removeMarker(marker.value, true) - markerClustererContext.reportMarkerRemoval() + markerClustererContext.requestRerender() } else { marker.value.setMap(null) diff --git a/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue b/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue index 222ee9f8..dee9c20b 100644 --- a/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +++ b/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue @@ -4,13 +4,13 @@ @@ -45,9 +45,9 @@ whenever(() => mapContext?.map.value, (map) => { once: true, }) -const markerClustererNeedsRerender = ref(false) +const markerClustererNeedsRerender = shallowRef(false) -function reportMarkerRemoval() { +function requestRerender() { markerClustererNeedsRerender.value = true } @@ -67,7 +67,13 @@ onUnmounted(() => { markerClusterer.value.setMap(null) }) -provide(MARKER_CLUSTERER_INJECTION_KEY, { markerClusterer, reportMarkerRemoval }) +provide( + MARKER_CLUSTERER_INJECTION_KEY, + { + markerClusterer, + requestRerender, + }, +) function setupMarkerClustererEventListeners(markerClusterer: MarkerClusterer) { markerClustererEvents.forEach((event) => {