From 17120537e334d1df627335fa2684582509cca445 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 1 Mar 2024 18:39:59 +0100 Subject: [PATCH] fix: make sure we wait for remote data before sending "dataloaded" event --- umap/static/umap/js/umap.layer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 8fd86b97..cc05a5c1 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -688,7 +688,7 @@ U.DataLayer = L.Evented.extend({ } // In case of maps pre 1.0 still around if (geojson._storage) geojson._storage.editMode = this.options.editMode - this.fromUmapGeoJSON(geojson) + await this.fromUmapGeoJSON(geojson) this.backupOptions() this.fire('loaded') this._loading = false @@ -703,10 +703,10 @@ U.DataLayer = L.Evented.extend({ this.fire('datachanged') }, - fromUmapGeoJSON: function (geojson) { + fromUmapGeoJSON: async function (geojson) { if (geojson._storage) geojson._umap_options = geojson._storage // Retrocompat if (geojson._umap_options) this.setOptions(geojson._umap_options) - if (this.isRemoteLayer()) this.fetchRemoteData() + if (this.isRemoteLayer()) await this.fetchRemoteData() else this.fromGeoJSON(geojson) this._loaded = true },