I’ve created a map provider so I can reuse my code to create multiple maps using cordova-plugin-googlemaps. I use the following function to reset the map as needed, for example, when the view changes.
resetMapContainer(div:string,visible:boolean,timer:number){
if(this.map){
setTimeout(()=>{
this.map.setDiv(div);
this.map.setVisible(visible);
},timer);
}
}
When that function gets called, XCode gives me the following errors:
ERROR: [ignore]map_1_923157887876.setDiv, because removed.
ERROR: [ignore]map_1_923157887876.setVisible, because removed.
My assumption is that this is due to the fact that the map provider doesn’t know which of the two maps I’m trying to reset.
So I’d like to be able to pass that function a specific map instance, e.g.
resetMapContainer(currentMapInstance: GoogleMap; div:string,visible:boolean,timer:number){
setTimeout(()=>{
currentMapInstance.setDiv(div);
currentMapInstance.setVisible(visible);
},timer);
}
Also worth noting, the map appears in a segment. The issue arises when I switch away from the map segment (which loads the first time) and then return. Here’s the code for that.
segmentChange(event){
if(event.value=='map'){
// reset on segment change...
this.mapProvider.resetMapContainer('tourmap',true,600);
}
}
ionViewWillEnter(){
// loads map and locations specific to each view
this.mapProvider.loadMap('tourmap',this.locations,true);
}
I’m not sure this is the right approach so I’m open to alternatives.
Thanks! – Erin