Merge remote-tracking branch 'upstream/pull/5573'
This commit is contained in:
commit
a6622e7d2c
1 changed files with 8 additions and 9 deletions
|
@ -115,19 +115,18 @@ L.OSM.Map = L.Map.extend({
|
|||
},
|
||||
|
||||
updateLayers: function (layerParam) {
|
||||
var layers = layerParam || "M";
|
||||
const oldBaseLayer = this.getMapBaseLayer();
|
||||
let newBaseLayer;
|
||||
|
||||
for (let i = this.baseLayers.length - 1; i >= 0; i--) {
|
||||
if (layers.indexOf(this.baseLayers[i].options.code) === -1) {
|
||||
this.removeLayer(this.baseLayers[i]);
|
||||
for (const layer of this.baseLayers) {
|
||||
if (!newBaseLayer || layerParam.includes(layer.options.code)) {
|
||||
newBaseLayer = layer;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = this.baseLayers.length - 1; i >= 0; i--) {
|
||||
if (layers.indexOf(this.baseLayers[i].options.code) >= 0 || i === 0) {
|
||||
this.addLayer(this.baseLayers[i]);
|
||||
return;
|
||||
}
|
||||
if (newBaseLayer !== oldBaseLayer) {
|
||||
if (oldBaseLayer) this.removeLayer(oldBaseLayer);
|
||||
if (newBaseLayer) this.addLayer(newBaseLayer);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue