-
Notifications
You must be signed in to change notification settings - Fork 0
/
hydrants.html
388 lines (337 loc) · 16.4 KB
/
hydrants.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<!DOCTYPE html>
<html lang="en">
<head>
<title>FRACTR: Fire Hydrants</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<?xml version="1.0" encoding="UTF-8"?>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<!-- Awesome Markers CSS -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css" rel="stylesheet">
<!--link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"-->
<link rel="stylesheet" href="./dist/leaflet.awesome-markers.css">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script src="https://kit.fontawesome.com/27cc898e82.js" crossorigin="anonymous"></script>
<!-- Local CSS -->
<link rel="stylesheet" href="style.css">
<!-- Leaflet CSS -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin=""/>
<!-- Leaflet JS library (must go AFTER Leaflet's CSS call) -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<!-- Ajax reads in local geoJson files asynchroneously -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<!-- ESRI Leaflet JS: implements search bar functionality -->
<script src="https://cdn-geoweb.s3.amazonaws.com/esri-leaflet/1.0.0-rc.2/esri-leaflet.js"></script>
<script src="https://cdn-geoweb.s3.amazonaws.com/esri-leaflet-geocoder/0.0.1-beta.5/esri-leaflet-geocoder.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn-geoweb.s3.amazonaws.com/esri-leaflet-geocoder/0.0.1-beta.5/esri-leaflet-geocoder.css">
</head>
<body>
<nav class="navbar navbar-dark bg-dark navbar-expand-md">
<div class="container">
<a class="navbar-brand" href="index.html">
<img src="images/logo2.png" alt="" width="30" height="24" class="d-inline-block align-text-top">
FRACTR
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-link" href="esn.html">Response Times by Service Zones</a>
<a class="nav-link" href="state.html">Response Times Across VT</a>
<a class="nav-link" href="hydrants.html">Fire Hydrant Coverage</a>
</div>
</div>
</div>
</nav>
<div class="container text-center">
<div class="p-4 my-4 bg-light text-dark rounded-3">
<h2>Map of Fire Hydrant Coverage</h2>
<p>The purpose of this map is to show areas that are 600 ft away or less from fire hydrants. This is a conservative number;
some fire departments are able to reach structures that are further away from hydrants.
The areas within 600 ft are depicted by circle polygons that are colored according to the fire hydrant's water flow rate.
A higher flow rate is better, because it means that firefighters can access a greater volume of water in a given timeframe.
Uncovered areas may require a tanker shuttle, when tanker trucks are used to haul water from the nearest source to the scene.
</p>
</div>
</div>
<div id="mapid" class="map-format"></div>
<script src="./dist/leaflet.awesome-markers.js"></script>
<script>
var mymap = L.map('mapid').setView([43.96, -72.6], 8);
var baseMap = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>, Data from <a href="https://geodata.vermont.gov/">Vermont GeoData Portal</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: 'pk.eyJ1IjoiamNhbWJlZm9ydCIsImEiOiJja2x6Ym4xaGQwOWUxMnVyM3J2aW54bXhuIn0.vIUQw48WSxIujl74dYNqkA'
}).addTo(mymap);
mymap.setMaxBounds(mymap.getBounds().pad(1));
var googleHybrid = L.tileLayer('http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}',{
maxZoom: 18,
minZoom: 4,
subdomains:['mt0','mt1','mt2','mt3']
});
color_list = ['blue', 'green', 'orange','red', 'gray']
function water_style(feature) {
return {
fillColor: "#00008b",
weight: 0.5,
opacity: 1,
color: "#00008b",
fillOpacity: .8
}
}
// Search Bar
var searchControl = new L.esri.Controls.Geosearch().addTo(mymap);
var results = new L.LayerGroup().addTo(mymap);
searchControl.on('results', function(data) {
results.clearLayers();
for (var i = data.results.length - 1; i >= 0; i--) {
var marker = L.marker(data.results[i].latlng, {fillColor: "green"});
results.addLayer(marker);
}
});
// Path needs the trailing slash
base_dir = "./data/"
let municipal_path = base_dir.concat("Municipal_Hydrant_buffers.geojson");
let pressurized_path = base_dir.concat("Pressurized_Hydrant_buffers.geojson");
let dry_path = base_dir.concat("Dry_Hydrant_buffers.geojson");
let draft_site_path = base_dir.concat("Drafting_Site_buffers.geojson");
let unknown_path = base_dir.concat("Unknown_Type_buffers.geojson");
var municipal_hydrants = L.geoJSON(null, {
style: function (feature) {
flow_rate = feature.properties.FLOWRATE;
console.log(flow_rate);
switch (flow_rate) {
case "blue":
return {color: "blue"};
case "green":
return {color: "green"};
case "orange":
return {color: "orange"};
case "red":
return {color: "red"};
case "unknown":
return {color: "gray"};
default:
return {color: "gray"};
}
}
}).bindPopup(function (layer) {
var hydrant_flow = layer.feature.properties.FLOWRATE;
var hydrant_type = layer.feature.properties.HYDRANTTYPE;
var hydrant_id = layer.feature.properties.HYDRANTID;
var popup_text = "Hydrant ID: " + hydrant_id;
popup_text+= "<br>Hydrant type: " + hydrant_type;
popup_text+= "<br>Flow rate color: " + hydrant_flow;
return popup_text;
}).addTo(mymap);
var pressurized_hyrants = L.geoJSON(null, {
style: function (feature) {
flow_rate = feature.properties.FLOWRATE;
console.log(flow_rate);
switch (flow_rate) {
case "blue":
return {color: "blue"};
case "green":
return {color: "green"};
case "orange":
return {color: "orange"};
case "red":
return {color: "red"};
case "unknown":
return {color: "gray"};
default:
return {color: "gray"};
}
}
}).bindPopup(function (layer) {
var hydrant_flow = layer.feature.properties.FLOWRATE;
var hydrant_type = layer.feature.properties.HYDRANTTYPE;
var hydrant_id = layer.feature.properties.HYDRANTID;
var popup_text = "Hydrant ID: " + hydrant_id;
popup_text+= "<br>Hydrant type: " + hydrant_type;
popup_text+= "<br>Flow rate color: " + hydrant_flow;
return popup_text;
}).addTo(mymap);
var dry_hydrants = L.geoJSON(null, {
style: function (feature) {
flow_rate = feature.properties.FLOWRATE;
console.log(flow_rate);
switch (flow_rate) {
case "blue":
return {color: "blue"};
case "green":
return {color: "green"};
case "orange":
return {color: "orange"};
case "red":
return {color: "red"};
case "unknown":
return {color: "gray"};
default:
return {color: "gray"};
}
}
}).bindPopup(function (layer) {
var hydrant_flow = layer.feature.properties.FLOWRATE;
var hydrant_type = layer.feature.properties.HYDRANTTYPE;
var hydrant_id = layer.feature.properties.HYDRANTID;
var popup_text = "Hydrant ID: " + hydrant_id;
popup_text+= "<br>Hydrant type: " + hydrant_type;
popup_text+= "<br>Flow rate color: " + hydrant_flow;
return popup_text;
}).addTo(mymap);
var drafting_sites = L.geoJSON(null, {
style: function (feature) {
flow_rate = feature.properties.FLOWRATE;
console.log(flow_rate);
switch (flow_rate) {
case "blue":
return {color: "blue"};
case "green":
return {color: "green"};
case "orange":
return {color: "orange"};
case "red":
return {color: "red"};
case "unknown":
return {color: "gray"};
default:
return {color: "gray"};
}
}
}).bindPopup(function (layer) {
var hydrant_flow = layer.feature.properties.FLOWRATE;
var hydrant_type = layer.feature.properties.HYDRANTTYPE;
var hydrant_id = layer.feature.properties.HYDRANTID;
var popup_text = "Hydrant ID: " + hydrant_id;
popup_text+= "<br>Hydrant type: " + hydrant_type;
popup_text+= "<br>Flow rate color: " + hydrant_flow;
return popup_text;
}).addTo(mymap);
var unknown_hydrants = L.geoJSON(null, {
style: function (feature) {
flow_rate = feature.properties.FLOWRATE;
console.log(flow_rate);
switch (flow_rate) {
case "blue":
return {color: "blue"};
case "green":
return {color: "green"};
case "orange":
return {color: "orange"};
case "red":
return {color: "red"};
case "unknown":
return {color: "gray"};
default:
return {color: "gray"};
}
}
}).bindPopup(function (layer) {
var hydrant_flow = layer.feature.properties.FLOWRATE;
var hydrant_type = layer.feature.properties.HYDRANTTYPE;
var hydrant_id = layer.feature.properties.HYDRANTID;
var popup_text = "Hydrant ID: " + hydrant_id;
popup_text+= "<br>Hydrant type: " + hydrant_type;
popup_text+= "<br>Flow rate color: " + hydrant_flow;
return popup_text;
}).addTo(mymap);
$.getJSON(municipal_path, function(data) {
municipal_hydrants.addData(data);
});
$.getJSON(pressurized_path, function(data) {
pressurized_hyrants.addData(data);
});
$.getJSON(dry_path, function(data) {
dry_hydrants.addData(data);
});
$.getJSON(draft_site_path, function(data) {
drafting_sites.addData(data);
});
$.getJSON(unknown_path, function(data) {
unknown_hydrants.addData(data);
});
// $.getJSON(water_path, function(data) {
// water.setStyle(water_style);
// water.addData(data);
// });
// mymap.on('zoomend', function() {
// var zoomlevel = mymap.getZoom();
// if (zoomlevel <15){
// if (mymap.hasLayer(water)) {
// mymap.removeLayer(water);
// } else {
// console.log("no water layer active");
// }
// }
// if (zoomlevel >= 15){
// if (mymap.hasLayer(water)){
// console.log("layer already added");
// } else {
// mymap.addLayer(water);
// }
// }
// console.log("Current Zoom Level =" + zoomlevel)
// });
var overlays = {
"Satellite Base Map": googleHybrid,
"Municipal Hydrants": municipal_hydrants,
"Pressurized Hydrants": pressurized_hyrants,
"Dry Hydrants": dry_hydrants,
"Drafting Sites": drafting_sites,
"Unknown Hydrant Type": unknown_hydrants
};
L.control.layers(null, overlays, {collapsed: false}).addTo(mymap);
function getColor(d) {
return d.includes("Blue") ? color_list[0] :
d.includes("Green") ? color_list[1]:
d.includes("Orange") ? color_list[2] :
d.includes("Red") ? color_list[3] :
d.includes("unknown") ? color_list[4] :
'#FFEDA0';
}
// Include a map legend
var legend = L.control({position: 'bottomright'});
legend.onAdd = function (mymap) {
var div = L.DomUtil.create('div', 'info legend'),
labels = ["Red hydrants: < 500 gpm",
"Orange Hydrants: 500-999 gpm",
"Green Hydrants: 1,000–1,499 gpm",
"Blue Hydrants: > 1,500 gpm",
"Hydrants with unknown flowrate"];
// loop through list of polygon labels
for (var i = 0; i < labels.length; i++) {
div.innerHTML +=
'<i style="background:' + getColor(labels[i]) + '"></i> ' +
labels[i] + '<br>';
}
return div;
};
legend.addTo(mymap);
</script>
<div class="container">
<div class="p-4 my-4 bg-light text-dark rounded-3">
<h4>How to Navigate the Map</h4>
<p>This is an interactive map, so please toggle around. The upper-left corner provides buttons to zoom in (+) and out (-).
The magnifying glass lets you search for any address of your choosing and will zoom in to that location.
The upper-right corner lets you toggle the different data layers on and off. By checking the box, you can toggle the layer on
and by unchecking the box you can toggle the layer off. The bottom-right corner provides a legend for the different hydrant flow rates.
</p>
</div>
</div>
</body>
</html>