-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
40 lines (39 loc) · 1.11 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function updateMap()
{
fetch("/data.json")
.then(response => response.json())
.then(rsp => {
console.log(rsp.data);
rsp.data.forEach(element => {
latitude = element.latitude;
longitude = element.longitude;
cases = element.infected;
if (cases>1000) {
color=`rgb(255,0,0)`;
}
else if(cases<1000 && cases>700){
color =`rgb(255, 51, 0)`;
}
else if(cases<700 && cases>500){
color =`rgb(255, 80, 80)`;
}
else if(cases<500 && cases>300){
color =`rgb(255, 102, 0)`;
}
else if(cases<300 && cases>100){
color =`rgb(255, 204, 0)`;
}
else if(cases<100){
color =`rgb(153, 204, 0)`;
}
// Mark on the map
new mapboxgl.Marker({
draggable: false,
color : color
})
.setLngLat([longitude, latitude])
.addTo(map);
});
})
}
updateMap();