Skip to content

Commit cc617fc

Browse files
committed
issue allenhwkim#466, firing map idle event when get map instance from the existing pool
1 parent b18f688 commit cc617fc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

services/ng-map-pool.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @desc map instance pool
1212
*/
1313
var mapInstances = [];
14-
var $window, $document;
14+
var $window, $document, $timeout;
1515

1616
var add = function(el) {
1717
var mapDiv = $document.createElement("div");
@@ -47,6 +47,11 @@
4747
var map = find(el);
4848
if (!map) {
4949
map = add(el);
50+
} else {
51+
/* firing map idle event, which is used by map controller */
52+
$timeout(function() {
53+
google.maps.event.trigger(map, 'idle');
54+
}, 100);
5055
}
5156
map.inUse = true;
5257
return map;
@@ -63,16 +68,16 @@
6368
map.inUse = false;
6469
};
6570

66-
var NgMapPool = function(_$document_, _$window_) {
67-
$document = _$document_[0], $window = _$window_;
71+
var NgMapPool = function(_$document_, _$window_, _$timeout_) {
72+
$document = _$document_[0], $window = _$window_, $timeout = _$timeout_;
6873

6974
return {
7075
mapInstances: mapInstances,
7176
getMapInstance: getMapInstance,
7277
returnMapInstance: returnMapInstance
7378
};
7479
};
75-
NgMapPool.$inject = [ '$document', '$window' ];
80+
NgMapPool.$inject = [ '$document', '$window', '$timeout'];
7681

7782
angular.module('ngMap').factory('NgMapPool', NgMapPool);
7883

0 commit comments

Comments
 (0)