Tabs persistance and google maps


#1

Hello!
Im a newbie on ionic and angularjs. Im building an app just for testing, and im facing some design pattern troubles, hope you can help me out!

Im trying to build a tab navigation, and put a google map on one tab.
Well, the problem is that every time I open the maptab the map re-instantiates again, consuming resources. I could use a service to save the map parameters/pins/markers…etc and it works, but how can i save the map itself, or the entire view so it doesnt get destroyed and re-instanted when changing tabs??

Thanks!


#2

I’m not a definitive source on this, but I don’t know that it can be done. With AngularJS controllers and views are destroyed when another view is loaded.

Maybe read through this and see if there is any guidance, but I think they have essentially the same problem:


Leaflet map and ion-nav-view
#3

Hey! Thanks for your answer.

I spent a few hours on this. I came across this angular directive for google maps https://github.com/dylanfprice/angular-gm that takes care of the memory leaking, reusing the same instance of the map.