nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 25d776cb379148777373f44cb0c3d6daac41a7d1
parent 78b4da2113681af49312b4e74442987a6564f72a
Author: Sergey Orlov <wladimirych@gmail.com>
Date:   Fri, 12 Mar 2021 10:46:09 +0100

layers: trigger "add" event for new version of custom layer.

We need to add layer to map before adding it to layer control, so the
event is not triggered automatically. The event is needed to update
hash state.

Fixes #664.

Diffstat:
Msrc/lib/leaflet.control.layers.configure/index.js | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/lib/leaflet.control.layers.configure/index.js b/src/lib/leaflet.control.layers.configure/index.js @@ -474,15 +474,19 @@ function enableConfig(control, {layers, customLayersOrder}) { const newLayer = this.createCustomLayer(newFieldValues); this._customLayers.splice(layerPos, 0, newLayer); - if ( + const newLayerVisible = ( this._map.hasLayer(layer.layer) && // turn off layer if changing from overlay to baselayer (!layer.layer.options.isOverlay || newLayer.layer.options.isOverlay) - ) { + ); + if (newLayerVisible) { this._map.addLayer(newLayer.layer); } this._map.removeLayer(layer.layer); this.updateEnabledLayers(); + if (newLayerVisible) { + newLayer.layer.fire('add'); + } this.hideCustomLayerForm(); },