I have decided to use AngularUI Map plugin to render Google Maps map within one of my views.
The template looks like this:
<div id="map">
<div ui-map="map" ui-options="mapOptions" id="map-canvas"
ui-event="{'map-click': 'placeMarker($event, $params)'}">
</div>
</div>
The map is stored in the map scope variable of the controller. I've forced this behavior by explicitly creating this variable in the controller body: #scope.map = {};
What I would like is to externalize this map object to a service to avoid recreating it every time the view is accessed.
The service I wrote looks like this:
evee.factory('mapService', [function () {
return {
};
}]);
And the controller code looks like this:
var LocationController = function($scope, mapService) {
$scope.map = mapService;
...
I can't make it work, the plugin always reinitializes the map. Should I drop the usage of the plugin and adopt a solution such as this non-plugin solution ?
Thank you.