-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.html
343 lines (290 loc) · 13.8 KB
/
state.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>FRACTR: VT State</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 Response Times, bounded by the state of Vermont</h2>
<p>The purpose of this map is to show how far a fire engine can respond from any fire station in 2, 5, 10, and 20 minutes.
The response times are calculated starting at each of the fire stations and use road speed limits to determine
how far an engine can travel in the given timeframe. The assumption with this map is that the closest
station to the incident will respond to that call. However, this is not true in practice. See Response Times
by Service Zones to see a map of response times according to fire department service zones.
</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,
minZoom: 4,
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']
});
//L.tileLayer('data/building_density_res/{z}/{x}/{y}.png').addTo(mymap);
color_list = ['#1e1656', '#8b2a57', '#c26b4c', '#cbbb65']
function poly_style1(feature) {
return {
fillColor: color_list[0],
weight: 0.5,
opacity: 1,
color: 'white',
fillOpacity: .3
}
}
function poly_style2(feature) {
return {
fillColor: color_list[1],
weight: 0.5,
opacity: 1,
color: 'white',
fillOpacity: .3
}
}
function poly_style3(feature) {
return {
fillColor: color_list[2],
weight: 0.5,
opacity: 1,
color: 'white',
fillOpacity: .3
}
}
function poly_style4(feature) {
return {
fillColor: color_list[3],
weight: 0.5,
opacity: 1,
color: 'white',
fillOpacity: .3
}
}
function zones_style(feature) {
return {
fillColor: 'gray',
weight: 2,
opacity: 1,
color: 'red',
fillOpacity: 0
}
}
// 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 poly2_path = base_dir.concat("2.geojson");
let poly5_path = base_dir.concat("5.geojson");
let poly10_path = base_dir.concat("10.geojson");
let poly20_path = base_dir.concat("20.geojson");
let stations_path = base_dir.concat("updated_stations_coords.geojson");
let zones_path = base_dir.concat("esn_zones.geojson");
var poly2 = L.geoJSON(null, {style:poly_style1} );
var poly5 = L.geoJSON(null, {style:poly_style2} );
var poly10 = L.geoJSON(null, {style:poly_style3} );
var poly20 = L.geoJSON(null, {style:poly_style4} ).addTo(mymap);
var zones = L.geoJSON(null, {style:zones_style} );
var stations = L.geoJson(null, {
pointToLayer: function(feature, latLng) {
// Generate marker based on the department type
dept_type = feature.properties.Department_Type;
//console.log(dept_type);
switch (dept_type) {
case "Volunteer Department":
var icon_type = 'fire-extinguisher';
var icon_prefix = 'fa';
var marker_color = 'red';
//console.log("it's a volunteer department");
break;
case "Career Department":
var icon_type = 'fire-extinguisher';
var icon_prefix = 'fa';
var marker_color = 'orange';
//console.log("it's a career department");
break;
case "Combination":
var icon_type = 'fire-extinguisher';
var icon_prefix = 'fa';
var marker_color = 'purple';
//console.log("it's a combo department");
break;
default:
var icon_type = 'fire-extinguisher';
var icon_prefix = 'fa';
var marker_color = 'darkred';
//console.log("it's an unknown type");
}
var icon_marker = L.AwesomeMarkers.icon({
icon: icon_type,
prefix: icon_prefix,
markerColor: marker_color
});
var marker = new L.marker(latLng, {
icon: icon_marker,
//title: this.tooltip
});
var latLon = feature.geometry.coordinates[1] + "," +
feature.geometry.coordinates[0] + ",0,0";
//console.log(latLon)
var popupText = "Name: " + feature.properties.Department_Name;
popupText += "<br>Type: " +feature.properties.Department_Type;
marker.bindPopup(popupText);
return marker;
}
});
// Use JQuery to import the geoJSON file
$.getJSON(poly2_path, function (data) {
poly2.setStyle(poly_style1);
poly2.addData(data);
});
$.getJSON(poly5_path, function (data) {
poly5.setStyle(poly_style2);
poly5.addData(data);
});
$.getJSON(poly10_path, function (data) {
poly10.setStyle(poly_style3);
poly10.addData(data);
});
$.getJSON(poly20_path, function (data) {
poly20.setStyle(poly_style4);
poly20.addData(data);
});
$.getJSON(stations_path, function(data) {
stations.addData(data);
});
$.getJSON(zones_path, function (data) {
zones.setStyle(zones_style);
zones.addData(data);
});
// Add the 20 minute polygon layer first (should be on the bottom)
poly20.addTo(mymap);
// Wait at least half a second to allow for other geojsons to download
// Then add each one to the map, in the order 10, then 5, then 2 on top
setTimeout(function() {
poly10.addTo(mymap);
}, 1000);
setTimeout(function() {
poly5.addTo(mymap);
}, 1100);
setTimeout(function() {
poly2.addTo(mymap);
}, 1200);
// Allow user to toggle layers
var overlays = {
"Satellite Base Map": googleHybrid,
"2 minutes": poly2,
"5 minutes": poly5,
"10 minutes": poly10,
"20 minutes": poly20,
"Stations": stations,
"Fire Dept. Emergency Service Zones": zones
}
L.control.layers(null, overlays, {collapsed: false}).addTo(mymap);
function getColor(d) {
return d.includes("2 ") ? color_list[0] :
d.includes("5 ") ? color_list[1] :
d.includes("10 ") ? color_list[2] :
d.includes("20 ") ? color_list[3] :
'#FFEDA0';
}
// Include a map legend
var legend = L.control({ position: 'bottomright' });
legend.onAdd = function (mymap) {
var div = L.DomUtil.create('div', 'info legend'),
labels = ["2 Minute Response",
"5 Minute Response",
"10 Minute Response",
"20 Minute Reponse"];
// 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 you 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 response time layers.
As the color of the polygons gets lighter, the response time increases and vice versa.
</p>
</div>
</div>
</body>
</html>