Description
🐛 The bug
Environment
nuxt: 3.12.3
@nuxt/scripts: 0.8.3
node: v22.4.0
Reproduction
-
Use the ScriptGoogleMaps component as demonstrated in the official documentation:
-
Follow the setup instructions and ensure the component is implemented according to the demo.
-
Navigate to another page and observe the console for errors when the component is unmounted.
Describe the bug
In the beforeUnmount hook of the ScriptGoogleMaps component, there is an attempt to call marker.setMap(null) on marker elements. However, this method does not exist on the marker object.
The type of mapMarker is:
mapMarkers: Map (Ref)
Key: "FL54SOqWoQ"
Value: Promise
Upon unmounting the component, the following error is thrown:
Unhandled error during execution of beforeUnmount hook: Uncaught (in promise) TypeError: marker.setMap is not a function
🛠️ To reproduce
https://stackblitz.com/edit/nuxt-starter-fsbb83?file=pages%2Findex.vue
🌈 Expected behavior
In the beforeUnmount
hook, the component should properly clean up marker elements without throwing an error.
ℹ️ Additional context
No response