Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Destroying scope should only remove its own defaults #346

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
295 changes: 198 additions & 97 deletions dist/ui-leaflet.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/ui-leaflet.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/ui-leaflet.min.no-header.js

Large diffs are not rendered by default.

295 changes: 198 additions & 97 deletions dist/ui-leaflet_dev_mapped.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ui-leaflet_dev_mapped.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/directives/layercontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ angular.module('ui-leaflet').directive('layercontrol', function ($filter, leafle
});
});

leafletScope.$watch('layers.overlays', function(newOverlayLayers) {
leafletScope.$watchCollection('layers.overlays', function (newOverlayLayers) {
var overlaysArray = [];
var groupVisibleCount = {};
leafletData.getLayers().then(function() {
Expand Down Expand Up @@ -259,7 +259,7 @@ angular.module('ui-leaflet').directive('layercontrol', function ($filter, leafle
}
scope.overlaysArray = overlaysArray;
});
}, true);
});
});
}
};
Expand Down
290 changes: 190 additions & 100 deletions src/directives/layers.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/directives/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion src/services/leafletLayerHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ angular.module('ui-leaflet')
custom: {
createLayer: function (params) {
if (params.layer instanceof L.Class) {
return angular.copy(params.layer);
return params.layer;
}
else {
$log.error('[AngularJS - Leaflet] A custom layer must be a leaflet Class');
Expand Down
7 changes: 5 additions & 2 deletions src/services/leafletMapDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ 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) {
if (!isDefined(scopeId)){
scopeId = 'main';
}
delete defaults[scopeId];
},
getDefaults: function (scopeId) {
var mapId = obtainEffectiveMapId(defaults, scopeId);
Expand Down
2 changes: 1 addition & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = (karma) => {
'test/unit/bootstrap.coffee',
'test/unit/**/*.js',
'test/unit/**/*.coffee',
'bower_components/Leaflet.PolylineDecorator/leaflet.polylineDecorator.js',
'bower_components/Leaflet.PolylineDecorator/dist/leaflet.polylineDecorator.js',
//do not include those specs for jasmine html runner by karma kama_jasmine_runner.html
{pattern:'test/**/**/*.coffee', included: false},
{pattern: 'dist/**/*.js.map', included: false}
Expand Down