-
Notifications
You must be signed in to change notification settings - Fork 0
/
pollutant-trend-images.html
106 lines (78 loc) · 3.8 KB
/
pollutant-trend-images.html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<head>
<title></title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://raw.githubusercontent.com/nychealth/EH-dataportal/prod-deploy/scss/theme.css">
<style>
#map {
width:100%;
height:90vh;
}
/* use this class to position elements off-screen so that only screen readers encounter them*/
.sronly {
position: absolute;
left: -9999px;
}
</style>
</head>
<body>
<div class="container-fluid p-0">
<div class="row no-gutters p-0 m-0">
<div class="col" style="background-image:URL()">
<div class="row no-gutters">
<div style="display:inline-block">
<button type="button" class="btn btn-sm btn-outline-dark active" value="BC">BC</button>
<button type="button" class="btn btn-sm btn-outline-dark" value="NO">NO</button>
<button type="button" class="btn btn-sm btn-outline-dark" value="NO2">NO<sub>2</sub></button>
<button type="button" class="btn btn-sm btn-outline-dark" value="O3">O<sub>3</sub></button>
<button type="button" class="btn btn-sm btn-outline-dark" value="PM25">PM<sub>2.5</sub></button>
<button type="button" class="btn btn-sm btn-outline-dark" value="SO2">SO<sub>2</sub></button>
</div>
<div style="" class="ml-auto">
<input type="range" min="2009" max="2020" value="2020" class="slider mt-1" id="myRange">
<span id="yearPrint" class="float-right">2020</span>
</div>
</div>
<div class="row no-gutters">
<div class="col-12">
<img id="raster" src="images/BC_2020.png" style="width:100%; height: auto;">
</div>
</div>
</div>
</div>
</div>
<script>
// update image
var chosenYear = 2020
var pollutant = "BC"
function updateRaster() {
var filename = pollutant + "_" + chosenYear + ".png"
// console.log(filename)
document.getElementById('raster').src = "images/" + filename
}
// Change var pollutant and polYear on Button Click
const btns = document.querySelectorAll(".btn")
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function() {
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace(" active", "");
this.className += " active";
pollutant = this.value
polYear = pollutant+chosenYear
updateRaster()
});
}
// Change year value when dragging slider
const year = document.getElementById('myRange')
year.addEventListener("change",function(){
chosenYear = year.value;
polYear = pollutant+chosenYear
document.getElementById('yearPrint').innerHTML = year.value
updateRaster()
})
</script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>