Skip to content

Google Maps: color-mode reactivity fails with single mapId (Cloud-based styling) #726

Description

@mtzrmzia

🐛 The bug

The ScriptGoogleMaps component does not reactively update the map's colorScheme when the Nuxt color-mode changes if a single mapId is used. According to the documentation, providing a mapIds object or relying on auto-detection should handle the theme switch, but the map remains in the initial state (usually Light) even when the application's color mode and the HTML class successfully switch to dark.

The documentation suggests using two different Map IDs, but modern Google Maps Cloud-based styling allows a single Map ID to host both light and dark themes. Using a single ID for both keys in :map-ids or passing it via map-options results in no visual update or the error: A Map's mapId property cannot be changed after initial Map render if forced via reactivity.

To Reproduce

  1. Configure a Google Map ID in Google Cloud Console with both "Light" and "Dark" color schemes assigned.
  2. Use the following implementation:
<script setup lang="ts">const mapOptions = { center: { lat: 23.96736602061825, lng: -102.1055418897208 }, zoom: 5,};</script>
<template>
<ScriptGoogleMaps
:map-ids="{ light: 'id_light', // ID CLARO dark: 'id_dark', // ID OSCURO }"
:map-options="mapOptions"
/>
</template>
  1. Toggle the Nuxt color mode.
  2. Observe that the UI changes to dark mode, but the map stays in light mode.
ImageImage

🛠️ To reproduce

https://stackblitz.com/edit/nuxt-starter-jyttjtdk?file=pages%2Fmap.vue

🌈 Expected behavior

The map should call setOptions({ colorScheme: 'DARK' }) (or 'LIGHT') on the existing instance without re-rendering the entire component or requiring a unique ID per theme, especially since Google's new API supports dynamic scheme switching on a single Map ID.

ℹ️ Additional context

Operating systemmacOS 25.4.0
CPUApple M2 Pro (10 cores)
Node.js versionv22.13.0
nuxt/cli version3.34.0
Package manageryarn@4.7.0
Nuxt version4.4.2
Nitro version2.13.1
Buildervite@7.3.1
Configapp, compatibilityDate, components, css, devtools, experimental, fonts, image, modules, piniaPluginPersistedstate, runtimeConfig, scripts, ssr, typescript, ui, vite
Modules@nuxt/eslint@1.15.2, @nuxt/ui@4.5.1, @nuxt/image@2.0.0, @vueuse/nuxt@14.2.1, @pinia/nuxt@0.11.3, pinia-plugin-persistedstate/nuxt@4.7.1, @nuxt/scripts@1.0.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions