-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (27 loc) · 884 Bytes
/
index.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
function updateMap() {
console.log("Updating map with realtime data")
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>255){
color = "rgb(255, 0, 0)";
}
else{
color = `rgb(${cases}, 0, 0)`;
}
// Marking on the map
new mapboxgl.Marker({
draggable: false,
color: color
}).setLngLat([longitude, latitude])
.addTo(map);
});
})
}
let interval = 20000;
setInterval( updateMap, interval);