forked from meliharvey/sidewalkwidths-nyc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
394 lines (363 loc) · 12.4 KB
/
index.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
389
390
391
392
393
394
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Sidewalk Widths Toronto</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<link rel='icon' href='favicon.ico?' type='image/x-icon'/ >
<script src="https://api.mapbox.com/mapbox-gl-js/v1.9.1/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v1.9.1/mapbox-gl.css" rel="stylesheet" />
<style>
body {
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
background-color: #03070d;
}
#info {
position: fixed;
width: 80%;
max-width: 400px;
height: 80%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 30px;
color: #c9d3d9;
background-color: #0b0d13;
z-index: 1000;
border-radius: 20px;
}
#info-content {
width: 100%;
height: 80%;
overflow: auto;
font-size: 1em;
}
#info-content h1 {
margin-top: 0;
}
#info-content h3 {
margin-bottom: 0;
}
#info-content p {
width: 100%;
overflow: auto;
}
#info-button {
height: 50px;
padding: 1em;
text-align: center;
}
#info-button button {
padding: 0.5em;
color: #c9d3d9;
font-size: 1.25em;
font-weight: bold;
background-color: #2f5994;
outline: 0;
border: 0;
border-radius: 10px;
}
#info-button button:hover {
background-color: #a99521;
transition: 0.1s ease-in-out;
}
#open-info {
position: fixed;
background-color: #2f5994;
margin-left: 10px;
margin-top: 10px;
width: 40px;
height: 40px;
text-align: center;
outline: 0;
border: 0;
border-radius: 20px;
z-index: 2000;
}
#open-info h2 {
font-family: "Times New Roman", Times, serif;
font-weight: bold;
color: #cfedff;
margin-top: 8px;
}
#open-info:hover {
background-color: #a99521;
transition: 0.1s ease-in-out;
}
a:link {
color: #3d77ca;
text-decoration: none;
}
a:visited {
color: #3d77ca;
text-decoration: none;
}
a:hover {
color: #a99521;
text-decoration: underline;
}
a:active {
color: #a99521;
text-decoration: underline;
}
.mapboxgl-ctrl-group {
background: #2f5994;
}
.mapboxgl-ctrl-group button+button {
border-top: 1px solid #000;
}
.mapboxgl-ctrl button:not(:disabled):hover {
background-color: #a99521;
transition: 0.1s ease-in-out;
}
.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='white'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E");
}
.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='white'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E");
}
.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='white'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath d='M10.5 16l4 8 4-8h-8z' fill='black'/%3E%3C/svg%3E");
}
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {
border-top-color: #03070d;
}
.mapboxgl-popup-content {
color: white;
font-weight: bold;
background-color: #03070d;
border: 1px solid white;
border-radius: 10px;
box-shadow: 0px 3px 10px rgba(0, 0, 0, .8);
}
.mapboxgl-popup-content .name {
margin: 0;
margin-bottom: 0.5em;
}
.mapboxgl-popup-content .width {
margin: 0;
margin-bottom: 0.2em;
font-size: 2.5em;
}
.mapboxgl-popup-content .message {
margin: 0;
margin-bottom: 0.2em;
font-size: 1.5em;
}
</style>
</head>
<body>
<div id="info">
<div id="info-content">
<h3>Welcome to</h3>
<h1>Sidewalk Widths Toronto</h1>
<p>This map is intended to give an impression of how sidewalk widths impact the ability of pedestrians to practice social distancing. Widths were determined from the <a href="https://open.toronto.ca/dataset/topographic-mapping-physical-area-of-sidewalks/">City of Toronto's open sidewalk data</a>. This source data was not verfied for accuracy or completeness. The sidewalk data also does not include off-street trails and multi-use paths, which may offer additional routes for pedestrians.</p>
<p>This site borrows <a href="https://www.github.com/meliharvey/sidewalkwidths-nyc">methods and code</a> from Meli Harvey's <a href="http://www.sidewalkwidths.nyc/">Sidewalk Widths NYC project</a>, adapted to Toronto's context. To learn more about how this dataset was produced, visit the <a href="https://github.com/sharedstreets/sidewalkwidths-toronto">Sidewalk Widths Toronto GitHub page</a>.</p>
<!-- <p>This map is intended to give an impression of how sidewalk widths impact the ability of pedestrians to practice social distancing. Sidewalk width information was provided by the <a href="https://www.oaklandca.gov/topics/sidewalks">City of Oakland</a>, using its most recent (2006) sidewalk inventory. This source data was not verfied for accuracy or completeness. This map is based on <a href="https://www.github.com/meliharvey/sidewalkwidths-nyc"></a>Meli Harvey's <a href="http://www.sidewalkwidths.nyc/">Sidewalk Widths NYC project</a> and associated <a href="https://www.github.com/meliharvey/sidewalkwidths-nyc">source code.</a></p> -->
<!-- <p>This map is intended to give an impression of how sidewalk widths impact the ability of pedestrians to practice social distancing. Widths were determined from the <a href="https://data.drcog.org/dataset/sidewalk-polygons-2018">Denver Regional Council of Government (DRCOG)'s 2018 Regional Planimetric Data Project</a>. This source data was not verfied for accuracy or completeness. This site borrows <a href="https://www.github.com/meliharvey/sidewalkwidths-nyc">methods and code</a> from Meli Harvey's <a href="http://www.sidewalkwidths.nyc/">Sidewalk Widths NYC project</a></p>
<p>To learn more about how this dataset was produced, visit the <a href="https://www.github.com/meliharvey/sidewalkwidths-nyc">GitHub page</a>.</p> -->
<p></p>
<p><small>DISCLAIMER<br>
Do not use this map to make decisions that impact your health or safety. Other important factors like sidewalk obstructions, population density, and pedestrian activity are not accounted for in this dataset. Dense areas often have wide sidewalks, but could be too crowded to keep a safe distance. Less populated areas will almost certainly have narrower sidewalks, but it may be easy to keep a safe distance. Local knowledge and other information are critical for making decisions about using and managing city streets.
</small></p>
</div>
<div id="info-button" onclick="closeInfo()">
<button>Explore the Map</button>
</div>
</div>
<button id="open-info" onclick="openInfo()">
<h2>i</h2>
</button>
<div id="map"></div>
<script>
function closeInfo() {
var x = document.getElementById("info");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
function openInfo() {
var x = document.getElementById("info");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
}
mapboxgl.accessToken = 'pk.eyJ1IjoidHJhbnNwb3J0cGFydG5lcnNoaXAiLCJhIjoiY2s5ZW9kZnR5MDJpNjNtcDRzaDRoaW5vdyJ9.88UoaHJBnCDoIqT05XsJvA';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/transportpartnership/ck9eobamu2ojb1io1yppz1uhn',
center: [-79.3808, 43.6493],
zoom: 16,
maxZoom: 22,
minZoom: 12,
maxBounds: [
[-79.689, 43.451], // Southwest coordinates
[-79.089, 43.851] // Northeast coordinates
],
hash: true
});
map.addControl(new mapboxgl.NavigationControl());
map.on('load', function() {
map.addSource('sidewalks', {
type: 'vector',
url: 'mapbox://transportpartnership.avtbz3wy'
});
map.addLayer({
'id': 'sidewalks',
'type': 'line',
'source': 'sidewalks',
'source-layer': 'sidewalkwidths_toronto-cthez3',
'layout': {
'line-cap': 'round',
},
"paint": {
"line-color": [
"step",
["get", "width"],
"hsl(0, 85%, 40%)",
6,
"hsl(31, 87%, 45%)",
9,
"hsl(55, 80%, 56%)",
12,
"hsl(83, 88%, 44%)",
16,
"hsl(130, 69%, 41%)",
20,
"#2ea5e5",
87.6,
"hsl(212, 81%, 44%)"
],
"line-width": [
"interpolate",
["linear"],
["zoom"],
13,
0.8,
15,
2.5,
16,
4,
20,
14
],
"line-opacity": 0.96
}
},
'road-label'
);
map.addLayer(
{
'id': '3d-buildings',
'source': 'composite',
'source-layer': 'building',
'filter': ['==', 'extrude', 'true'],
'type': 'fill-extrusion',
'minzoom': 16,
'paint': {
'fill-extrusion-color': '#1f2432',
'fill-extrusion-height': [
'interpolate',
['linear'],
['zoom'],
16, 0,
16.05, ['get', 'height']
],
'fill-extrusion-base': [
'interpolate',
['linear'],
['zoom'],
16, 0,
16.05, ['get', 'min_height']
],
'fill-extrusion-opacity': [
'interpolate',
['linear'],
['zoom'],
16, 0.4,
17, 0.95
]
}
},
'road-label'
);
var popup = new mapboxgl.Popup({
closeButton: false,
closeOnClick: false
});
function addPopup(e) {
map.getCanvas().style.cursor = 'pointer';
var lineWidth = e.features[0].properties.width
var lineColor = e.features[0].layer.paint['line-color']
var coordinates = e.lngLat;
if (lineWidth < 1) {
var message = 'This street does not have a sidewalk.'
var lineColor = '#961113'
} else if (lineWidth >= 1 && lineWidth < 6) {
var message = 'This path is too narrow for social distancing.'
var lineColor = '#bd0f0f'
} else if (lineWidth >= 6 && lineWidth < 9) {
var message = 'This path is too narrow for social distancing.'
var lineColor = '#d7760f'
} else if (lineWidth >= 9 && lineWidth < 12) {
var message = 'Social distancing may be difficult on this path.'
var lineColor = '#e9da35'
} else if (lineWidth >= 12 && lineWidth < 16) {
var message = 'Social distancing should be possible on this path.'
var lineColor = '#87d30d'
} else if (lineWidth >= 16 && lineWidth < 20) {
var message = 'Social distancing should be easy on this path.'
var lineColor = '#20b138'
} else {
var message = 'This path is great for social distancing!'
var lineColor = '#2ea5e5'
}
var description = (
'<div class="name">Sidewalk Width:</div>' +
'<div class="width">' + Math.round(lineWidth * 10 * 0.3048) / 10) + ' m</div>' +
'<div class="message">' + message + '</div>'
popup.setLngLat(coordinates)
popup.setHTML(description)
popup.addTo(map)
popup._content.style.color = lineColor
popup._content.style.borderColor = lineColor
if (popup._tip.offsetParent.className.includes('mapboxgl-popup-anchor-bottom')) {
popup._tip.style.borderTopColor = lineColor
}
if (popup._tip.offsetParent.className.includes('mapboxgl-popup-anchor-top')) {
popup._tip.style.borderBottomColor = lineColor
}
if (popup._tip.offsetParent.className.includes('mapboxgl-popup-anchor-right')) {
popup._tip.style.borderLeftColor = lineColor
}
if (popup._tip.offsetParent.className.includes('mapboxgl-popup-anchor-left')) {
popup._tip.style.borderRightColor = lineColor
}
popup.addTo(map)
}
map.on('touchstart', 'sidewalks', function(e) {
addPopup(e);
})
map.on('mousemove', 'sidewalks', function(e) {
addPopup(e);
});
map.on('mouseleave', 'sidewalks', function() {
map.getCanvas().style.cursor = '';
popup.remove();
});
});
</script>
</body>
</html>