Merge pull request #1938 from umap-project/1934-empty-map-datalayers

fix: Distinction between clearing data vs. layers
This commit is contained in:
David Larlet 2024-06-25 08:11:33 -04:00 committed by GitHub
commit 921bed1d99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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