From 0b031dc7ccc4bf5e62c9981cd01493ec7f35f609 Mon Sep 17 00:00:00 2001 From: David Larlet Date: Mon, 24 Jun 2024 16:27:13 -0400 Subject: [PATCH] fix: Distinction between clearing data vs. layers Fix #1934 --- umap/static/umap/js/umap.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 6d68f910..84d567c2 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -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)