This commit is contained in:
parent
f9d03d2d19
commit
d25eaa9334
16
incidence.js
16
incidence.js
@ -8,9 +8,23 @@ Script.setWidget(widget)
|
|||||||
Script.complete()
|
Script.complete()
|
||||||
|
|
||||||
async function createWidget(items) {
|
async function createWidget(items) {
|
||||||
|
let location
|
||||||
|
if(args.widgetParameter) {
|
||||||
|
const fixedCoordinates = args.widgetParameter.split(",").map(parseFloat)
|
||||||
|
location = {
|
||||||
|
latitude: fixedCoordinates[0],
|
||||||
|
longitude: fixedCoordinates[1]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Location.setAccuracyToThreeKilometers()
|
Location.setAccuracyToThreeKilometers()
|
||||||
const location = await Location.current()
|
location = await Location.current()
|
||||||
|
}
|
||||||
const data = await new Request(apiUrl(location)).loadJSON()
|
const data = await new Request(apiUrl(location)).loadJSON()
|
||||||
|
if(!data || !data.features || !data.features.length) {
|
||||||
|
const errorList = new ListWidget()
|
||||||
|
errorList.addText("Keine Ergebnisse für den aktuellen Ort gefunden.")
|
||||||
|
return errorList
|
||||||
|
}
|
||||||
const attr = data.features[0].attributes
|
const attr = data.features[0].attributes
|
||||||
const incidence = attr.cases7_per_100k.toFixed(1)
|
const incidence = attr.cases7_per_100k.toFixed(1)
|
||||||
const cityName = attr.GEN
|
const cityName = attr.GEN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user