diff --git a/src/directives/leaflet.js b/src/directives/leaflet.js index 11e93acf..7949a4fe 100644 --- a/src/directives/leaflet.js +++ b/src/directives/leaflet.js @@ -135,7 +135,7 @@ angular.module('ui-leaflet', ['nemLogging']).directive('leaflet', }); scope.$on('$destroy', function () { - leafletMapDefaults.reset(); + leafletMapDefaults.reset(attrs.id); map.remove(); leafletData.unresolveMap(attrs.id); }); diff --git a/src/services/leafletMapDefaults.js b/src/services/leafletMapDefaults.js index 285f94b0..e46012ec 100644 --- a/src/services/leafletMapDefaults.js +++ b/src/services/leafletMapDefaults.js @@ -47,8 +47,9 @@ angular.module('ui-leaflet').factory('leafletMapDefaults', function ($q, leaflet // Get the _defaults dictionary, and override the properties defined by the user return { - reset: function () { - defaults = {}; + reset: function (scopeId) { + var mapId = obtainEffectiveMapId(defaults, scopeId); + delete defaults[mapId]; }, getDefaults: function (scopeId) { var mapId = obtainEffectiveMapId(defaults, scopeId);