Skip to content

Commit 5a30fcc

Browse files
dmishnejuristr
authored andcommitted
fix(ol directive): watch destroy
1 parent 43a4133 commit 5a30fcc

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/directives/openlayers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ angular.module('openlayers-directive', ['ngSanitize']).directive('openlayers', f
7575
view: view
7676
});
7777

78+
scope.$on('$destroy', function() {
79+
olData.resetMap(attrs.id);
80+
});
81+
7882
// If no layer is defined, set the default tileLayer
7983
if (!attrs.customLayers) {
8084
var l = {

src/services/olData.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,10 @@ angular.module('openlayers-directive').service('olData', function($log, $q) {
6868
return id;
6969
}
7070

71+
this.resetMap = function(scopeId) {
72+
if (angular.isDefined(maps[scopeId])) {
73+
delete maps[scopeId];
74+
}
75+
};
76+
7177
});

0 commit comments

Comments
 (0)