fix: tilelayer plus icon where never displayed

We were testing the length of the `_layers` property, which where
sliced to `maxShown` before…
This commit is contained in:
Yohan Boniface 2024-09-04 11:23:20 +02:00
parent c33adcf0e7
commit ee7439a0f9

View file

@ -795,13 +795,14 @@ U.TileLayerControl = L.Control.IconLayers.extend({
} }
}) })
} }
this._allLayers = layers
L.Control.IconLayers.prototype.setLayers.call(this, layers.slice(0, this.maxShown)) L.Control.IconLayers.prototype.setLayers.call(this, layers.slice(0, this.maxShown))
if (this.map.selected_tilelayer) this.setActiveLayer(this.map.selected_tilelayer) if (this.map.selected_tilelayer) this.setActiveLayer(this.map.selected_tilelayer)
}, },
_createLayerElements: function () { _createLayerElements: function () {
L.Control.IconLayers.prototype._createLayerElements.call(this) L.Control.IconLayers.prototype._createLayerElements.call(this)
if (Object.keys(this._layers).length <= this.maxShown) return if (Object.keys(this._allLayers).length <= this.maxShown) return
const lastRow = this._container.querySelector( const lastRow = this._container.querySelector(
'.leaflet-iconLayers-layersRow:last-child' '.leaflet-iconLayers-layersRow:last-child'
) )