fix: Distinction between clearing data vs. layers

Fix #1934
This commit is contained in:
David Larlet 2024-06-24 16:27:13 -04:00
parent 8dfed0dc62
commit 0b031dc7cc
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD

View file

@ -13,7 +13,7 @@ L.Map.mergeOptions({
// we cannot rely on this because of the y is overriden by Leaflet
// See https://github.com/Leaflet/Leaflet/pull/9201
// And let's remove this -y when this PR is merged and released.
demoTileInfos: { 's': 'a', 'z': 9, 'x': 265, 'y': 181, '-y': 181, 'r': '' },
demoTileInfos: { s: 'a', z: 9, x: 265, y: 181, '-y': 181, r: '' },
licences: [],
licence: '',
enableMarkerDraw: true,
@ -1505,8 +1505,15 @@ U.Map = L.Map.extend({
L.DomUtil.createButton(
'button umap-empty',
advancedButtons,
L._('Empty'),
this.empty,
L._('Clear data'),
this.emptyDataLayers,
this
)
L.DomUtil.createButton(
'button umap-empty',
advancedButtons,
L._('Remove layers'),
this.removeDataLayers,
this
)
}
@ -1517,13 +1524,6 @@ U.Map = L.Map.extend({
this.clone,
this
)
L.DomUtil.createButton(
'button umap-empty',
advancedButtons,
L._('Delete all layers'),
this.empty,
this
)
L.DomUtil.createButton(
'button umap-download',
advancedButtons,
@ -1687,12 +1687,18 @@ U.Map = L.Map.extend({
}
},
empty: function () {
removeDataLayers: function () {
this.eachDataLayerReverse((datalayer) => {
datalayer._delete()
})
},
emptyDataLayers: function () {
this.eachDataLayerReverse((datalayer) => {
datalayer.empty()
})
},
initLoader: function () {
this.loader = new L.Control.Loading()
this.loader.onAdd(this)