Skip to content

ScriptGoogleMaps: Error thrown in beforeUnmount hook #252

Closed
@Marfi333

Description

@Marfi333

🐛 The bug

Environment

nuxt: 3.12.3
@nuxt/scripts: 0.8.3
node: v22.4.0

Reproduction

  1. Use the ScriptGoogleMaps component as demonstrated in the official documentation:

  2. Follow the setup instructions and ensure the component is implemented according to the demo.

  3. 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

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