Merge pull request #1497 from jschleic/fix-rank-on-reordering

fix dirty flags when re-ordering layers
This commit is contained in:
Yohan Boniface 2023-12-31 11:16:06 +01:00 committed by GitHub
commit ced7f3d6ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -632,12 +632,14 @@ L.U.DataLayersControl = L.Control.extend({
function (e) { function (e) {
const layer = this.map.datalayers[e.src.dataset.id], const layer = this.map.datalayers[e.src.dataset.id],
other = this.map.datalayers[e.dst.dataset.id], other = this.map.datalayers[e.dst.dataset.id],
minIndex = Math.min(e.initialIndex, e.finalIndex) minIndex = Math.min(layer.getRank(), other.getRank()),
maxIndex = Math.max(layer.getRank(), other.getRank())
if (e.finalIndex === 0) layer.bringToTop() if (e.finalIndex === 0) layer.bringToTop()
else if (e.finalIndex > e.initialIndex) layer.insertBefore(other) else if (e.finalIndex > e.initialIndex) layer.insertBefore(other)
else layer.insertAfter(other) else layer.insertAfter(other)
this.map.eachDataLayerReverse((datalayer) => { this.map.eachDataLayerReverse((datalayer) => {
if (datalayer.getRank() >= minIndex) datalayer.isDirty = true if (datalayer.getRank() >= minIndex && datalayer.getRank() <= maxIndex)
datalayer.isDirty = true
}) })
this.map.indexDatalayers() this.map.indexDatalayers()
}, },