This commit is contained in:
parent
f9d03d2d19
commit
d25eaa9334
18
incidence.js
18
incidence.js
@ -8,9 +8,23 @@ Script.setWidget(widget)
|
||||
Script.complete()
|
||||
|
||||
async function createWidget(items) {
|
||||
Location.setAccuracyToThreeKilometers()
|
||||
const location = await Location.current()
|
||||
let location
|
||||
if(args.widgetParameter) {
|
||||
const fixedCoordinates = args.widgetParameter.split(",").map(parseFloat)
|
||||
location = {
|
||||
latitude: fixedCoordinates[0],
|
||||
longitude: fixedCoordinates[1]
|
||||
}
|
||||
} else {
|
||||
Location.setAccuracyToThreeKilometers()
|
||||
location = await Location.current()
|
||||
}
|
||||
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 incidence = attr.cases7_per_100k.toFixed(1)
|
||||
const cityName = attr.GEN
|
||||
|
Loading…
Reference in New Issue
Block a user