diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index f9099fa6..b97fa58b 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1178,21 +1178,26 @@ L.U.Map.include({ }, }) +/* Used in view mode to define the current tilelayer */ L.U.TileLayerControl = L.Control.IconLayers.extend({ initialize: function (map, options) { const layers = [] - for (const layer of map.tilelayers) { + map.eachTileLayer((layer) => { layers.push({ title: layer.options.name, layer: layer, icon: L.Util.template(layer.options.url_template, map.demoTileInfos), }) - } - L.Control.IconLayers.prototype.initialize.call(this, layers, {position: 'topleft'}) - } + }) + L.Control.IconLayers.prototype.initialize.call(this, layers.slice(0, 10), { + position: 'topleft', + manageLayers: false + }) + this.on('activelayerchange', (e) => map.selectTileLayer(e.layer)) + }, }) - +/* Used in edit mode to define the default tilelayer */ L.U.TileLayerChooser = L.Control.extend({ options: { position: 'topleft',