„incidence.js“ ändern
This commit is contained in:
parent
1405e0b76e
commit
53e648a5e1
16
incidence.js
16
incidence.js
@ -1,5 +1,6 @@
|
||||
// Licence: Robert Koch-Institut (RKI), dl-de/by-2-0
|
||||
const apiUrl = (location) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=GEN,cases7_per_100k&geometry=51.375%2C12.361&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json`
|
||||
const apiUrl = (location) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=GEN,cases7_per_100k&geometry=12.361%2C51.375&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json`
|
||||
const apiUrl2 = (location) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=GEN,cases7_per_100k&geometry=12.361%2C51.375&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json`
|
||||
const apiUrlStates = 'https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/Coronaf%E4lle_in_den_Bundesl%E4ndern/FeatureServer/0/query?where=1%3D1&outFields=cases7_bl_per_100k&returnGeometry=false&outSR=4326&f=json'
|
||||
|
||||
const widget = await createWidget()
|
||||
@ -26,6 +27,12 @@ async function createWidget(items) {
|
||||
label.font = Font.boldSystemFont(24)
|
||||
label.textColor = data.incidence >= 50 ? Color.red() : data.incidence >= 35 ? Color.orange() : Color.green()
|
||||
list.addText(data.areaName)
|
||||
|
||||
const label2 = list.addText(data2.incidence+"")
|
||||
label2.font = Font.boldSystemFont(24)
|
||||
label2.textColor = data2.incidence >= 50 ? Color.red() : data2.incidence >= 35 ? Color.orange() : Color.green()
|
||||
list.addText(data2.areaName)
|
||||
|
||||
if(data.shouldCache) {
|
||||
list.refreshAfterDate = new Date(Date.now() + 60*60*1000)
|
||||
}
|
||||
@ -42,7 +49,12 @@ async function getData() {
|
||||
if(location) {
|
||||
let data = await new Request(apiUrl(location)).loadJSON()
|
||||
const attr = data.features[0].attributes
|
||||
return { incidence: attr.cases7_per_100k.toFixed(1), areaName: attr.GEN, shouldCache: true };
|
||||
|
||||
let data2 = await new Request(apiUrl2(location)).loadJSON()
|
||||
const attr2 = data2.features[0].attributes
|
||||
|
||||
return { incidence: attr.cases7_per_100k.toFixed(1), areaName: attr.GEN, incidence2: attr2.cases7_per_100k.toFixed(1), areaName2: attr2.GEN, shouldCache: true };
|
||||
|
||||
} else {
|
||||
let data = await new Request(apiUrlStates).loadJSON()
|
||||
const incidencePerState = data.features.map((f) => f.attributes.cases7_bl_per_100k)
|
||||
|
Loading…
Reference in New Issue
Block a user