Skip to content

Commit 6653652

Browse files
committed
clean up of gMarkerManager markers in MarkerParentModel
1 parent bda7c82 commit 6653652

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

dist/angular-google-maps.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,13 +2290,19 @@ Nicholas McCready - https://twitter.com/nmccready
22902290
break;
22912291
case 'options':
22922292
if (this.validateCoords(scope.coords) && (scope.icon != null) && scope.options) {
2293-
return this.scope.gMarker.setMap(null)(this.scope.gMarker != null ? this.setGMarker(new google.maps.Marker(this.createMarkerOptions(scope.coords, scope.icon, scope.options, this.mapCtrl.getMap()))) : void 0);
2293+
if (this.scope.gMarker != null) {
2294+
this.scope.gMarker.setMap(null);
2295+
}
2296+
return this.setGMarker(new google.maps.Marker(this.createMarkerOptions(scope.coords, scope.icon, scope.options, this.mapCtrl.getMap())));
22942297
}
22952298
}
22962299
};
22972300

22982301
MarkerParentModel.prototype.setGMarker = function(gMarker) {
2299-
delete this.scope.gMarker;
2302+
if (this.scope.gMarker) {
2303+
delete this.scope.gMarker;
2304+
this.gMarkerManager.remove(this.scope.gMarker, false);
2305+
}
23002306
this.scope.gMarker = gMarker;
23012307
if (this.scope.gMarker) {
23022308
this.gMarkerManager.add(this.scope.gMarker, false);
@@ -2308,11 +2314,12 @@ Nicholas McCready - https://twitter.com/nmccready
23082314

23092315
MarkerParentModel.prototype.onDestroy = function(scope) {
23102316
var self;
2311-
if (this.scope.gMarker === void 0) {
2317+
if (!this.scope.gMarker) {
23122318
self = void 0;
23132319
return;
23142320
}
23152321
this.scope.gMarker.setMap(null);
2322+
this.gMarkerManager.remove(this.scope.gMarker, false);
23162323
delete this.scope.gMarker;
23172324
return self = void 0;
23182325
};

0 commit comments

Comments
 (0)