diff --git a/umap/static/umap/js/modules/rendering/map.js b/umap/static/umap/js/modules/rendering/map.js index a3baeb3a..25b0b999 100644 --- a/umap/static/umap/js/modules/rendering/map.js +++ b/umap/static/umap/js/modules/rendering/map.js @@ -233,12 +233,8 @@ const ManageTilelayerMixin = { }, updateTileLayers: function () { - const callback = (tilelayer) => { - this.options.tilelayer = tilelayer.toJSON() - this._umap.isDirty = true - } if (this._controls.tilelayersChooser) { - this._controls.tilelayersChooser.openSwitcher({ callback, edit: true }) + this._controls.tilelayersChooser.openSwitcher({ edit: true }) } }, } diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 54061492..57adeb84 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -683,10 +683,13 @@ U.TileLayerChooser = L.Control.extend({ L.DomEvent.on( el, 'click', - function () { + () => { this.map.selectTileLayer(tilelayer) this.map._controls.tilelayers.setLayers() - if (options?.callback) options.callback(tilelayer) + if (options?.edit) { + this.map._umap.properties.tilelayer = tilelayer.toJSON() + this.map._umap.isDirty = true + } }, this )