forked from MapComplete/MapComplete
Also add timeout to template
This commit is contained in:
parent
6e2afefcba
commit
4c2ffdb4cf
1 changed files with 11 additions and 1 deletions
|
|
@ -18,10 +18,20 @@ function webgl_support() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function timeout(timeMS: number): Promise<{ layers: string[] }> {
|
||||||
|
await Utils.waitFor(timeMS)
|
||||||
|
return { layers: [] }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async function getAvailableLayers(): Promise<Set<string>> {
|
async function getAvailableLayers(): Promise<Set<string>> {
|
||||||
try {
|
try {
|
||||||
const host = new URL(Constants.VectorTileServer).host
|
const host = new URL(Constants.VectorTileServer).host
|
||||||
const status = await Utils.downloadJson("https://" + host + "/summary/status.json")
|
const status = await Promise.any([
|
||||||
|
Utils.downloadJson("https://" + host + "/summary/status.json"),
|
||||||
|
timeout(5000)
|
||||||
|
])
|
||||||
return new Set<string>(status.layers)
|
return new Set<string>(status.layers)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Could not get MVT available layers due to", e)
|
console.error("Could not get MVT available layers due to", e)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue