Toggle loading property while (re)loading layers

This commit is contained in:
D. Berge
2020-08-11 17:16:20 +02:00
parent 5341db7026
commit efbdb713df

View File

@@ -191,10 +191,12 @@ export default {
const query = new URLSearchParams({bbox, limit});
let requestsCount = 0;
for (const l of this.layerRefreshConfig.filter(i => !layerset || layerset.includes(i.layer))) {
if (map.hasLayer(l.layer)) {
// Firing all refresh events asynchronously, which is OK provided
// we don't have hundreds of layers to be refreshed.
requestsCount++;
await this.api([l.url(query)]).then( (layer) => {
l.layer.clearLayers();
if ((layer.features && layer.features.length < limit) || ("length" in layer && layer.length < limit)) {
@@ -202,9 +204,13 @@ export default {
} else {
console.log("Too much data from", l.url(query));
}
if (--requestsCount == 0) {
this.loading = false;
}
})
}
}
this.loading = requestsCount > 0;
},
...mapActions(["api"])