@@ -259,6 +259,21 @@ function isLocationQuery(s: string | any) {
259259 return typeof s === ' string' && (s .split (' ,' ).length > 2 || s .includes (' +' ))
260260}
261261
262+ type ScriptGoogleMapsCenter = ScriptGoogleMapsProps [' center' ] | google .maps .MapOptions [' center' ]
263+
264+ function getCenterWatchKey(center : ScriptGoogleMapsCenter ): string | undefined {
265+ const raw = toRaw (center )
266+ if (! raw )
267+ return undefined
268+ if (typeof raw === ' string' )
269+ return ` query:${raw } `
270+ const lat = typeof (raw as any ).lat === ' function' ? (raw as any ).lat () : (raw as any ).lat
271+ const lng = typeof (raw as any ).lng === ' function' ? (raw as any ).lng () : (raw as any ).lng
272+ if (lat != null && lng != null )
273+ return ` latlng:${lat },${lng } `
274+ return undefined
275+ }
276+
262277const queryToLatLngCache = new Map <string , google .maps .LatLng | google .maps .LatLngLiteral >()
263278
264279async function resolveQueryToLatLng(query : string ) {
@@ -449,14 +464,14 @@ onMounted(() => {
449464 // Clear centerOverride when the controlled center prop changes so external
450465 // updates take effect (otherwise centerOverride, written from the user's
451466 // pan during re-init, would permanently win over future prop updates).
452- watch ([() => props .center , () => props .mapOptions ?.center ], () => {
467+ watch ([() => getCenterWatchKey ( props .center ) , () => getCenterWatchKey ( props .mapOptions ?.center ) ], () => {
453468 centerOverride .value = undefined
454469 })
455- watch ([() => options .value .center , isMapReady , map ], async (next ) => {
470+ watch ([() => getCenterWatchKey ( options .value .center ) , isMapReady , map ], async () => {
456471 if (! map .value ) {
457472 return
458473 }
459- let center = toRaw (next [ 0 ] )
474+ let center = toRaw (options . value . center )
460475 if (center ) {
461476 if (isLocationQuery (center ) && isMapReady .value ) {
462477 center = await resolveQueryToLatLng (center as string )
0 commit comments