mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 03:42:37 +02:00
fix: do not load all datalayers at once (#2402)
Some maps have dozens, even hundreds of layers
This commit is contained in:
commit
a62bcf6d57
1 changed files with 6 additions and 2 deletions
|
@ -581,9 +581,13 @@ export default class Umap extends ServerStored {
|
||||||
this.fire('datalayersloaded')
|
this.fire('datalayersloaded')
|
||||||
const toLoad = []
|
const toLoad = []
|
||||||
for (const datalayer of this.datalayersIndex) {
|
for (const datalayer of this.datalayersIndex) {
|
||||||
if (datalayer.showAtLoad()) toLoad.push(datalayer.show())
|
if (datalayer.showAtLoad()) toLoad.push(() => datalayer.show())
|
||||||
}
|
}
|
||||||
await Promise.all(toLoad)
|
while (toLoad.length) {
|
||||||
|
const chunk = toLoad.splice(0, 10)
|
||||||
|
await Promise.all(chunk.map((func) => func()))
|
||||||
|
}
|
||||||
|
|
||||||
this.dataloaded = true
|
this.dataloaded = true
|
||||||
this.fire('dataloaded')
|
this.fire('dataloaded')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue