/** * @ngdoc factory * @name NgMapPool * @description * Provide map instance to avoid memory leak */ (function() { 'use strict'; /** * @memberof NgMapPool * @desc map instance pool */ var mapInstances = []; var $window, $document, $timeout; var add = function(el) { var mapDiv = $document.createElement("div"); mapDiv.style.width = "100%"; mapDiv.style.height = "100%"; el.appendChild(mapDiv); var map = new $window.google.maps.Map(mapDiv, {}); mapInstances.push(map); return map; }; var findById = function(el, id) { var notInUseMap; for (var i=0; i