inocan-group / vue3-google-map

A set of composable components for easy use of Google Maps in your Vue 3 projects.
https://vue3-google-map.com
MIT License
289 stars 58 forks source link

Reloading Component in SPA #22

Closed scottix closed 3 years ago

scottix commented 3 years ago

In a SPA, the component can get unMounted when I navigate to another page, but if I return to the page with the map or go to another page that has a map. The component doesn't get reinitialized, this is because the google map loader has already loaded previous api.

I think you should check if google.map is available, if is then you can just re-configure the map.

scottix commented 3 years ago

Another comment/issues I found. I was playing with the plugin and was able to reinitialize the map, but turns out there is a race condition with mapRef

mapRef is set to null and will only get initialized when the div is mounted. You don't see the issue right now because by the time the GoogleMap api loads the div is ready.

In the reinitialize case the api is already loaded but mapRef is null because it hasn't been mounted yet.

One solution would be is to put the promise in a variable and then use onMounted function continue loading.

HusamElbashir commented 3 years ago

Can you provide a minimal reproduction of these issues @scottix ?