From bb922d1418f351b504b9e8c35828704887f12a80 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 15 Aug 2023 22:55:59 +0200 Subject: [PATCH] Call DataLayer.show instead of manually adding layer to the map --- umap/static/umap/js/umap.layer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index a0d677e5..85f740ea 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -313,7 +313,7 @@ L.U.DataLayer = L.Evented.extend({ const Class = L.U.Layer[this.options.type] || L.U.Layer.Default this.layer = new Class(this) this.eachLayer((feature) => this.showFeature(feature)) - if (visible) this.map.addLayer(this.layer) + if (visible) this.show() this.propagateRemote() }, @@ -335,12 +335,15 @@ L.U.DataLayer = L.Evented.extend({ fetchData: function () { if (!this.umap_id) return + if (this._loading) return + this._loading = true this.map.get(this._dataUrl(), { callback: function (geojson, response) { this._last_modified = response.getResponseHeader('Last-Modified') this.fromUmapGeoJSON(geojson) this.backupOptions() this.fire('loaded') + this._loading = false }, context: this, })