From 58fb54408313d23b81f123accb169ebcc5ba7937 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sun, 4 Nov 2018 21:12:09 +0100 Subject: [PATCH] Fix missing remote datalayers when display data browser on load Another option would have been to wait for onceDataloaded instead of onceLoaded, but then the panel would never be displayed if some layer fails to load (eg. a 429 on Overpass). fix #509 --- umap/static/umap/js/umap.layer.js | 10 +++++++--- umap/static/umap/js/umap.slideshow.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index c80cf270..e06b733d 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -927,7 +927,11 @@ L.U.DataLayer = L.Evented.extend({ }, allowBrowse: function () { - return !!this.options.browsable && this.canBrowse() && this.isVisible() && this._index.length; + return !!this.options.browsable && this.canBrowse() && this.isVisible(); + }, + + hasData: function () { + return !!this._index.length; }, isVisible: function () { @@ -960,7 +964,7 @@ L.U.DataLayer = L.Evented.extend({ getPreviousBrowsable: function () { var id = this.getRank(), next, index = this.map.datalayers_index; while(id = index[++id] ? id : 0, next = index[id]) { - if (next === this || next.allowBrowse()) break; + if (next === this || (next.allowBrowse() && next.hasData())) break; } return next; }, @@ -968,7 +972,7 @@ L.U.DataLayer = L.Evented.extend({ getNextBrowsable: function () { var id = this.getRank(), prev, index = this.map.datalayers_index; while(id = index[--id] ? id : index.length - 1, prev = index[id]) { - if (prev === this || prev.allowBrowse()) break; + if (prev === this || (prev.allowBrowse() && prev.hasData())) break; } return prev; }, diff --git a/umap/static/umap/js/umap.slideshow.js b/umap/static/umap/js/umap.slideshow.js index 610dc4f2..78f006d5 100644 --- a/umap/static/umap/js/umap.slideshow.js +++ b/umap/static/umap/js/umap.slideshow.js @@ -61,7 +61,7 @@ L.U.Slideshow = L.Class.extend({ }, defaultDatalayer: function () { - return this.map.findDataLayer(function (d) { return d.allowBrowse(); }); + return this.map.findDataLayer(function (d) { return d.allowBrowse() && d.hasData(); }); }, timeSpinner: function () {