Fix reordering of layers (#2316)

Broken in the map split I guess.

(Only the first line is the fix, the other are just naming, cf the two
commits.)
This commit is contained in:
Yohan Boniface 2024-12-02 15:43:14 +01:00 committed by GitHub
commit d9998efc0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -596,7 +596,7 @@ export default class Umap extends ServerStored {
const panes = this._leafletMap.getPane('overlayPane')
this.datalayersIndex = []
for (const pane of panes) {
for (const pane of panes.children) {
if (!pane.dataset || !pane.dataset.id) continue
this.datalayersIndex.push(this.datalayers[pane.dataset.id])
}
@ -1425,13 +1425,13 @@ export default class Umap extends ServerStored {
row.dataset.id = stamp(datalayer)
})
const onReorder = (src, dst, initialIndex, finalIndex) => {
const layer = this.datalayers[src.dataset.id]
const other = this.datalayers[dst.dataset.id]
const minIndex = Math.min(layer.getRank(), other.getRank())
const maxIndex = Math.max(layer.getRank(), other.getRank())
if (finalIndex === 0) layer.bringToTop()
else if (finalIndex > initialIndex) layer.insertBefore(other)
else layer.insertAfter(other)
const movedLayer = this.datalayers[src.dataset.id]
const targetLayer = this.datalayers[dst.dataset.id]
const minIndex = Math.min(movedLayer.getRank(), targetLayer.getRank())
const maxIndex = Math.max(movedLayer.getRank(), targetLayer.getRank())
if (finalIndex === 0) movedLayer.bringToTop()
else if (finalIndex > initialIndex) movedLayer.insertBefore(targetLayer)
else movedLayer.insertAfter(targetLayer)
this.eachDataLayerReverse((datalayer) => {
if (datalayer.getRank() >= minIndex && datalayer.getRank() <= maxIndex)
datalayer.isDirty = true