Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lost of mouting container after navigation #100

Closed
zhaoweizhong opened this issue Feb 6, 2024 · 2 comments
Closed

Lost of mouting container after navigation #100

zhaoweizhong opened this issue Feb 6, 2024 · 2 comments

Comments

@zhaoweizhong
Copy link

When using NuxtLink or router.push() for navigation, I encounter an issue where the map disappears each time I navigate to a different page and then return.

I tried a workaround by assigning a random number to the map ID like :map-id="`map-${timestamp}`" so that the map component can be re-rendered every time. However, it results in the map controls persisting, resulting in duplicate controls appearing after each navigation:
image

Can anyone suggest a solution to this problem?

@AlexLavoie42
Copy link
Owner

AlexLavoie42 commented Feb 6, 2024

The map should be persistent across routes and should not need a reload. I am unsure if you are using multiple different maps across routes but that seems like the problem here.

For each map, you need to ensure that it has its own unique key that will remain the same for each map even on different routes. The problem with using timestamp is that the id changes all the time so the module creates a new map using the new id. Instead, just ensure you give a unique string for each maps id.

Of course I am just speculating here since I can't see your code. If you need further help please send a reproduction link using Stackblitz.

@zhaoweizhong
Copy link
Author

Thank you. I just located the problem, please check: https://stackblitz.com/edit/nuxt-starter-1nnuc9

When using multiple layouts and navigating from a page that contains a Map to another page with a different layout, then navigating back again, the Map component will disappear.

I'm not sure if it is an issue with this module, or just my problem on implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants