From 8fdddddc9ea932c3fa3cf6ab466a63168d3f19d4 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 12 Oct 2023 10:07:51 +0200 Subject: [PATCH] Prevent computing choropleth breaks for each feature when importing When importing a choropleth layer, the layer does not have a umap_id, thus "hasDataLoaded" is immediately true, instead of being true when all the "known" data is imported. At this point, I can't find a good reason to keep the check on umap_id, so let's remove and move forward. --- umap/static/umap/js/umap.layer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 084e93a5..accc9a90 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -135,7 +135,10 @@ L.U.Layer.Choropleth = L.FeatureGroup.extend({ [], this.datalayer.options.choropleth ) - this.datalayer.on('datachanged', this.redraw, this) + this.datalayer.onceDataLoaded(() => { + this.redraw() + this.datalayer.on('datachanged', this.redraw, this) + }) }, redraw: function () { @@ -717,7 +720,7 @@ L.U.DataLayer = L.Evented.extend({ }, hasDataLoaded: function () { - return !this.umap_id || this._dataloaded + return this._dataloaded }, setUmapId: function (id) {