44
55<script lang="ts">
66import { MarkerClusterer , type MarkerClustererOptions } from ' @googlemaps/markerclusterer'
7- import { inject , onUnmounted , provide , ref , shallowRef , type InjectionKey , type ShallowRef } from ' vue'
7+ import { inject , onUnmounted , provide , shallowRef , type InjectionKey , type ShallowRef } from ' vue'
88import { whenever } from ' @vueuse/core'
99import { MAP_INJECTION_KEY } from ' ./ScriptGoogleMaps.vue'
1010
1111export const MARKER_CLUSTERER_INJECTION_KEY = Symbol (' marker-clusterer' ) as InjectionKey <{
1212 markerClusterer: ShallowRef <MarkerClusterer | undefined >
13- reportMarkerRemoval : () => void
13+ requestRerender : () => void
1414}>
1515 </script >
1616
@@ -45,9 +45,9 @@ whenever(() => mapContext?.map.value, (map) => {
4545 once: true ,
4646})
4747
48- const markerClustererNeedsRerender = ref (false )
48+ const markerClustererNeedsRerender = shallowRef (false )
4949
50- function reportMarkerRemoval () {
50+ function requestRerender () {
5151 markerClustererNeedsRerender .value = true
5252}
5353
@@ -67,7 +67,13 @@ onUnmounted(() => {
6767 markerClusterer .value .setMap (null )
6868})
6969
70- provide (MARKER_CLUSTERER_INJECTION_KEY , { markerClusterer , reportMarkerRemoval })
70+ provide (
71+ MARKER_CLUSTERER_INJECTION_KEY ,
72+ {
73+ markerClusterer ,
74+ requestRerender ,
75+ },
76+ )
7177
7278function setupMarkerClustererEventListeners(markerClusterer : MarkerClusterer ) {
7379 markerClustererEvents .forEach ((event ) => {
0 commit comments