I’ve taken the standard maps nightly example on codepen:
And inserted it into a multipage app, I’ve put in a whole load of logic to load up google loader then google maps then the map itself on the relevant page. This all works perfectly, until you go to another page and come back???
I’ve got tests in to make sure that google loader and google maps and the map have loaded and aren’t reloaded when you reenter the page with the map. This is fine. I’m also storing the google maps map object that gets created in a $rootScope object. I can recover the map by doing a bit of a hack by appending the googlemap.getDiv() onto the div on every $ionicView.enter, but it’s a bit horrible.
The second option is to store the map object in a $scope object, and test for the existence of the scope object and create the object on non-existence, so…
if($scope.map===undefined){
mapOptions{blah blah blah};
$scope.map = new google.maps.Map(document.getElementById(“map”),mapOptions);
}
but the $scope.map is always undefined on reentry to page. I’m starting to wonder if this is a page cache thing, but I thought the default behaviour was all pages and scopes are cached unless you specify otherwise???
EDIT: Creating a plunker to see if I can demonstrate it…