From 1b60b46a3faf68e4fba9fc00a7d455c600b07667 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 1 Sep 2023 11:52:38 +0200 Subject: [PATCH 1/2] Delete old options after consuming them --- umap/static/umap/js/umap.layer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 46d1fee7..0fd5fbfc 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -253,9 +253,11 @@ L.U.DataLayer = L.Evented.extend({ // Retrocompat if (this.options.remoteData && this.options.remoteData.from) { this.options.fromZoom = this.options.remoteData.from + delete this.options.remoteData.from } if (this.options.remoteData && this.options.remoteData.to) { this.options.toZoom = this.options.remoteData.to + delete this.options.remoteData.to } this.backupOptions() this.connectToMap() From d89d2287b94a6e84fc2dbbd68a7c2a60db075aa5 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 1 Sep 2023 12:03:19 +0200 Subject: [PATCH 2/2] Fix datalayers with min/maxZoom never sending dataloaded event --- umap/static/umap/js/umap.js | 4 ++-- umap/static/umap/js/umap.layer.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 7848add6..c8d4ff6e 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -407,9 +407,9 @@ L.U.Map.include({ } this.eachDataLayer(function (datalayer) { if (force && !datalayer.hasDataLoaded()) datalayer.show() - if (datalayer.displayedOnLoad() || force) datalayer.onceLoaded(decrementToLoad) + if (datalayer.showAtLoad() || force) datalayer.onceLoaded(decrementToLoad) else decrementToLoad() - if (datalayer.displayedOnLoad() || force) + if (datalayer.showAtLoad() || force) datalayer.onceDataLoaded(decrementDataToLoad) else decrementDataToLoad() }) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 0fd5fbfc..c829a23f 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -261,7 +261,7 @@ L.U.DataLayer = L.Evented.extend({ } this.backupOptions() this.connectToMap() - if (this.displayedOnLoad() && this.showAtZoom()) this.show() + if (this.showAtLoad()) this.show() if (!this.umap_id) this.isDirty = true this.onceLoaded(function () { @@ -270,7 +270,7 @@ L.U.DataLayer = L.Evented.extend({ // Only layers that are displayed on load must be hidden/shown // Automatically, others will be shown manually, and thus will // be in the "forced visibility" mode - if (this.displayedOnLoad()) this.map.on('zoomend', this.onZoomEnd, this) + if (this.autoLoaded()) this.map.on('zoomend', this.onZoomEnd, this) }, onMoveEnd: function (e) { @@ -283,7 +283,11 @@ L.U.DataLayer = L.Evented.extend({ if (this.showAtZoom() && !this.isVisible()) this.show() }, - displayedOnLoad: function () { + showAtLoad: function () { + return this.autoLoaded() && this.showAtZoom() + }, + + autoLoaded: function () { return ( (this.map.datalayersOnLoad && this.umap_id &&