-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
66 lines (57 loc) · 2.12 KB
/
index.js
File metadata and controls
66 lines (57 loc) · 2.12 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function GetSortOrder(prop) {
return function (a, b) {
if (a[prop] > b[prop]) {
return 1;
} else if (a[prop] < b[prop]) {
return -1;
}
return 0;
}
}
function updateMap() {
fetch("./cntry.json")
.then(response => {
return response.json()
})
.then((rsp) => {
// console.log(rsp.ref_country_codes[0].latitude);
// console.log(rsp.ref_country_codes[0].longitude);
console.log(rsp.ref_country_codes.length);
rsp.ref_country_codes.sort(GetSortOrder("deaths"));
// array.sort(GetSortOrder("EmployeeName"))
console.log(rsp.ref_country_codes)
for (index = 0; index < rsp.ref_country_codes.length; index++) {
// rsp.data.forEach(element => {
console.log(rsp.ref_country_codes[index].deaths, rsp.ref_country_codes[index].longitude, rsp.ref_country_codes[index].latitude);
let lat = rsp.ref_country_codes[index].latitude;
let long = rsp.ref_country_codes[index].longitude;
// console.log(`${index+1}:`, lat);
// console.log(`${index+1}:`, long);
cases = rsp.ref_country_codes[index].deaths;
// console.log("case :"+cases);
if (cases >= 5000) {
color = "#b30000";
}
else if (cases >= 1000 && cases < 5000) {
color = "red";
}
else if (cases >= 500 && cases < 1000) {
color = "orange";
}
else if (cases > 100 && cases < 500) {
color = '#ffff4d';
}
else if (cases < 100)
color = "rgb(102, 204, 0)";
// Mark on the map
new mapboxgl.Marker({
draggable: false,
color: color
// visibility:0.1
})
.setLngLat([long, lat])
.addTo(map);
}
})
}
updateMap();