-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (28 loc) · 861 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
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.confirmed;
if(cases>255){
color="rgb(255, 0, 0)";
}
else{
color="rgb(${cases},0,0)"
}
new mapboxgl.Marker({
draggable: false,
color:color
})
.setLngLat([longitude, latitude])
.addTo(map);
})
})
}
let interval=20000;
setInterval(updatemap,interval);
//updatemap();