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
This commit is contained in:
Yohan Boniface 2018-11-04 21:12:09 +01:00
parent ca0c8c421e
commit 58fb544083
2 changed files with 8 additions and 4 deletions

View file

@ -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;
},

View file

@ -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 () {