Restore active layers (#205)
This commit is contained in:
parent
708b35f642
commit
ef41a9e5ff
4 changed files with 93 additions and 31 deletions
|
|
@ -92,7 +92,9 @@
|
|||
var layerString = decodeURIComponent(layerEncoded);
|
||||
|
||||
if (layerString) {
|
||||
obj = this._getLayerFromString(layerString);
|
||||
obj = this.options.layersControl.getLayerFromString(
|
||||
layerString
|
||||
);
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
|
@ -138,7 +140,7 @@
|
|||
layers.forEach(
|
||||
L.bind(function(obj, index, array) {
|
||||
if (obj) {
|
||||
layersControl.activateLayer(obj.layer);
|
||||
layersControl.activateLayer(obj);
|
||||
if (obj && !obj.overlay) {
|
||||
added = true;
|
||||
}
|
||||
|
|
@ -156,34 +158,15 @@
|
|||
var objList = this.options.layersControl.getActiveLayers();
|
||||
var layerList = objList.map(
|
||||
L.bind(function(obj) {
|
||||
return encodeURIComponent(this._toLayerString(obj));
|
||||
return encodeURIComponent(
|
||||
this.options.layersControl.toLayerString(obj)
|
||||
);
|
||||
}, this)
|
||||
);
|
||||
|
||||
return layerList.join(this.options.layerSeparator);
|
||||
},
|
||||
|
||||
_toLayerString: function(obj) {
|
||||
return obj.layer.id ? obj.layer.id : obj.name;
|
||||
},
|
||||
|
||||
_getLayerFromString: function(layerString) {
|
||||
var layersControl = this.options.layersControl;
|
||||
var obj = layersControl.getLayerById(layerString);
|
||||
|
||||
if (!obj) {
|
||||
// fallback to name for custom and config layers
|
||||
obj = layersControl.getLayer(layerString);
|
||||
|
||||
if (!obj) {
|
||||
// legacy layer name support
|
||||
obj = layersControl.getLayerByLegacyName(layerString);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
removeFrom: function(map) {
|
||||
if (this.changeTimeout) {
|
||||
clearTimeout(this.changeTimeout);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue