Hi!
I have an app using ionic with vuejs and i add in my project a page with a map using the @capacitor/google-maps plugin.
This problem only appear on android (not tested on IOS) and works fine on web.
So I have a map on a tab page when I first go to this tab the map loads and works find but if I change tabs and go back the map not showing up.
In my code I say that every time the page will be seen it create the map and when the page will be leave the map is removed.
In my log I can see this process without getting errors, the stranger things is that I use the same code in an other page (but not on tab) and it works perfectly fine on this page.
Here is a sample of my code.
<script setup>
import {
IonPage,
onIonViewWillEnter,
onIonViewWillLeave
} from '@ionic/vue';
import { GoogleMap } from '@capacitor/google-maps';
const mapID = 'mapPage';
const apiKey = process.env.VUE_APP_GOOGLE_MAPS_API;
var map = null;
onIonViewWillEnter( async () => {
this.map = await GoogleMap.create({
id: mapID,
element: document.getElementById(mapID),
apiKey: apiKey,
config: {
center: {
lat: 33.6,
lng: -117.9,
},
zoom: 13,
disableDefaultUI: true,
clickableIcons: false,
},
});
})
onIonViewWillLeave(() => {
if (this.map) {
this.map.destroy();
}
})
</script>
<template>
<ion-page>
<capacitor-google-map :id="mapID"></capacitor-google-map>
</ion-page>
</template>
Someone have any idea from where this error came from ?
Thanks for your help!