commit 6261adefa4f41c71580f43f6596f9dd61b9b4166
parent 0962bf81c01ea06ec94f33f46d234add977ca6e8
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Thu, 4 Dec 2025 22:52:06 +0100
leaflet.control.layers.configure: rename/refactor functions updating layers
Diffstat:
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/lib/leaflet.control.layers.configure/index.js b/src/lib/leaflet.control.layers.configure/index.js
@@ -118,7 +118,7 @@ function enableConfig(control, {layers, customLayersOrder}) {
layer.enabled = enabled;
layer.checked = ko.observable(enabled);
}
- this.updateEnabledLayers();
+ this.updateLayers();
},
_onConfigButtonClick: function() {
@@ -207,7 +207,7 @@ function enableConfig(control, {layers, customLayersOrder}) {
layer.enabled = false;
}
}
- this.updateEnabledLayers(newEnabledLayers);
+ this.updateLayers(newEnabledLayers);
this.hideSelectWindow();
},
@@ -235,7 +235,7 @@ function enableConfig(control, {layers, customLayersOrder}) {
);
},
- updateEnabledLayers: function(addedLayers) {
+ updateLayersListControl: function(addedLayers) {
const disabledLayers = [...this._allLayers, ...this._customLayers()].filter((l) => !l.enabled);
disabledLayers.forEach((l) => this._map.removeLayer(l.layer));
[...this._layers].forEach((l) => this.removeLayer(l.layer));
@@ -252,7 +252,7 @@ function enableConfig(control, {layers, customLayersOrder}) {
this.addBaseLayer(l.layer, l.title);
}
if (!isOverlay && this._map.hasLayer(l.layer)) {
- hasBaselayerOnMap = true;
+ hasBaselayerOnMap = true;
}
}
);
@@ -265,6 +265,10 @@ function enableConfig(control, {layers, customLayersOrder}) {
}
}
}
+ },
+
+ updateLayers: function(addedLayers) {
+ this.updateLayersListControl(addedLayers);
this.saveSettings();
},
@@ -293,9 +297,8 @@ function enableConfig(control, {layers, customLayersOrder}) {
layer.enabled = true;
}
}
- this.updateEnabledLayers();
+ this.updateLayers();
}
- this.saveSettings();
return originalUnserializeState.call(this, values);
},
@@ -442,7 +445,7 @@ function enableConfig(control, {layers, customLayersOrder}) {
layer.checked = ko.observable(true);
this._customLayers.push(layer);
this.hideCustomLayerForm();
- this.updateEnabledLayers();
+ this.updateLayers();
},
createCustomLayer: function(fieldValues) {
@@ -531,7 +534,7 @@ function enableConfig(control, {layers, customLayersOrder}) {
this._map.addLayer(newLayer.layer);
}
this._map.removeLayer(layer.layer);
- this.updateEnabledLayers();
+ this.updateLayers();
if (newLayerVisible) {
newLayer.layer.fire('add');
}
@@ -541,7 +544,7 @@ function enableConfig(control, {layers, customLayersOrder}) {
onCustomLayerDeletelClicked: function(layer) {
this._map.removeLayer(layer.layer);
this._customLayers.remove(layer);
- this.updateEnabledLayers();
+ this.updateLayers();
this.hideCustomLayerForm();
},