Control the tilelayer change, instead of letting iconLayers do it

We want to control min/max zoom and such.
This commit is contained in:
Yohan Boniface 2023-12-15 16:16:53 +01:00
parent fe9f4b4a48
commit afd57d6806

View file

@ -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',