-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
297 lines (280 loc) · 17.4 KB
/
index.html
File metadata and controls
297 lines (280 loc) · 17.4 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PEI National Dashboard</title>
<script>
(() => {
try {
const themeMode = localStorage.getItem('pei-theme-mode');
if (themeMode === 'light' || themeMode === 'dark') {
document.documentElement.setAttribute('data-theme', themeMode);
}
} catch (error) {
console.warn('Unable to restore theme preference.', error);
}
})();
</script>
<!-- ⚡ Bolt: Preconnect to Mapbox API to accelerate TLS handshakes for tiles and metadata -->
<link rel="preconnect" href="https://api.mapbox.com">
<link rel="dns-prefetch" href="https://api.mapbox.com">
<!-- ⚡ Bolt: Use direct `<link>` tags for Google Fonts instead of `@import` in CSS to prevent network waterfalls -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- ⚡ Bolt: Defer large Mapbox scripts to prevent blocking HTML parsing and First Contentful Paint -->
<script defer src="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css" rel="stylesheet" />
<script defer
src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-compare/v0.4.0/mapbox-gl-compare.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-compare/v0.4.0/mapbox-gl-compare.css"
rel="stylesheet" />
<script defer
src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.min.js"></script>
<link rel="stylesheet"
href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.css"
type="text/css" />
</head>
<body>
<div id="a11y-announcer" class="sr-only" aria-live="polite"></div>
<a href="#reset-view" class="skip-link">Skip to map</a>
<div id="sb" role="complementary" aria-label="Dashboard Controls">
<div class="sbh">
<button id="sb-close" type="button" title="Close controls (Esc)" aria-label="Close controls">Close</button>
<h1><span aria-hidden="true">🗺</span> PEI Dashboard <button type="button" class="info-btn" onclick="document.getElementById('info-modal').showModal()" title="About this Project (Press ?)" aria-label="About this Project">ℹ️</button></h1>
<p>Pedestrian Environment Index · Nationwide</p>
</div>
<!-- MODE -->
<div class="sec" role="group" aria-labelledby="lbl-mode">
<div class="lbl" id="lbl-mode">View Mode</div>
<div class="br">
<button class="btn on" id="m-single" aria-pressed="true" title="View a single metric layer"
onclick="setMode('single')">Single</button>
<button class="btn" id="m-diff" aria-pressed="false"
title="View the score difference between two metrics" onclick="setMode('diff')">PEI Diff</button>
</div>
<div class="br" style="margin-top:4px">
<button class="btn" id="m-pswipe" aria-pressed="false" title="Swipe to compare two metrics"
onclick="setMode('pswipe')"><span aria-hidden="true">⇔</span> PEI Swipe</button>
<button class="btn" id="m-yswipe" aria-pressed="false" title="Swipe to compare two years"
onclick="setMode('yswipe')"><span aria-hidden="true">⇔</span> Year Swipe</button>
</div>
</div>
<!-- YEAR (single + diff modes) -->
<div class="sec" id="ctl-year" role="group" aria-labelledby="lbl-year">
<div class="lbl" id="lbl-year">Year</div>
<div class="br">
<button class="btn on" id="y-2013" aria-pressed="true" onclick="setYear('2013')">2013</button>
<button class="btn" id="y-2017" aria-pressed="false" onclick="setYear('2017')">2017</button>
<button class="btn" id="y-2022" aria-pressed="false" onclick="setYear('2022')">2022</button>
</div>
</div>
<!-- SINGLE controls -->
<div class="sec" id="ctl-single">
<label class="lbl" for="pei-sel">Layer Display</label>
<select id="pei-sel" onchange="updateLayer()">
<option value="PEI_original">PEI Original (CDI·IDI·LDI·PDI)</option>
<option value="PEI_new">PEI New (RSI·GSI·BI·PTAL)</option>
<option value="PEI_combined">PEI Combined (All 8)</option>
<optgroup label="Original Indices">
<option value="CDI">Commercial Density (CDI)</option>
<option value="IDI">Intersection Density (IDI)</option>
<option value="LDI">Land Use Diversity (LDI)</option>
<option value="PDI">Population Density (PDI)</option>
</optgroup>
<optgroup label="New Indices">
<option value="RSI">Road Safety (RSI)</option>
<option value="RSI_new">New Road Safety (RSI_new)</option>
<option value="GSI">Green Space (GSI)</option>
<option value="BI">Bike Infrastructure (BI)</option>
<option value="PTAL">Public Transit Access (PTAL)</option>
</optgroup>
</select>
</div>
<!-- PEI DIFF controls -->
<div class="sec" id="ctl-diff" style="display:none">
<label class="lbl" for="diff-sel">Compare</label>
<select id="diff-sel" onchange="updateLayer()" aria-describedby="diff-hint">
<option value="orig-new">Original − New</option>
<option value="orig-comb">Original − Combined</option>
</select>
<p class="hint" id="diff-hint"><span aria-hidden="true">🟢</span> Green = new indices improve score<br><span
aria-hidden="true">🔴</span> Red = new indices reduce score</p>
</div>
<!-- PEI SWIPE controls -->
<div class="sec" id="ctl-pswipe" style="display:none">
<div class="lbl" id="lbl-pswipe-year">Year</div>
<div class="br" id="ps-yr-btns" role="group" aria-labelledby="lbl-pswipe-year"
aria-describedby="pswipe-hint">
<button class="btn on" id="ps-2013" aria-pressed="true" onclick="setPSwipeYear('2013')">2013</button>
<button class="btn" id="ps-2017" aria-pressed="false" onclick="setPSwipeYear('2017')">2017</button>
<button class="btn" id="ps-2022" aria-pressed="false" onclick="setPSwipeYear('2022')">2022</button>
</div>
<label class="sub-lbl" for="left-pei">Left Map</label>
<select id="left-pei" onchange="updateSplit()" aria-describedby="pswipe-hint">
<option value="PEI_original">PEI Original (CDI·IDI·LDI·PDI)</option>
<option value="PEI_new">PEI New (RSI·GSI·BI·PTAL)</option>
<option value="PEI_combined">PEI Combined (All 8)</option>
<optgroup label="Original Indices">
<option value="CDI">Commercial Density (CDI)</option>
<option value="IDI">Intersection Density (IDI)</option>
<option value="LDI">Land Use Diversity (LDI)</option>
<option value="PDI">Population Density (PDI)</option>
</optgroup>
<optgroup label="New Indices">
<option value="RSI">Road Safety (RSI)</option>
<option value="RSI_new">New Road Safety (RSI_new)</option>
<option value="GSI">Green Space (GSI)</option>
<option value="BI">Bike Infrastructure (BI)</option>
<option value="PTAL">Public Transit Access (PTAL)</option>
</optgroup>
</select>
<label class="sub-lbl" for="right-pei">Right Map</label>
<select id="right-pei" onchange="updateSplit()" aria-describedby="pswipe-hint">
<option value="PEI_new">PEI New (RSI·GSI·BI·PTAL)</option>
<option value="PEI_original">PEI Original (CDI·IDI·LDI·PDI)</option>
<option value="PEI_combined">PEI Combined (All 8)</option>
<optgroup label="Original Indices">
<option value="CDI">Commercial Density (CDI)</option>
<option value="IDI">Intersection Density (IDI)</option>
<option value="LDI">Land Use Diversity (LDI)</option>
<option value="PDI">Population Density (PDI)</option>
</optgroup>
<optgroup label="New Indices">
<option value="RSI">Road Safety (RSI)</option>
<option value="RSI_new">New Road Safety (RSI_new)</option>
<option value="GSI">Green Space (GSI)</option>
<option value="BI">Bike Infrastructure (BI)</option>
<option value="PTAL">Public Transit Access (PTAL)</option>
</optgroup>
</select>
<p class="hint" id="pswipe-hint" style="margin-top:6px">Drag the divider to compare maps side by side at the
same location.</p>
</div>
<!-- YEAR SWIPE controls -->
<div class="sec" id="ctl-yswipe" style="display:none">
<label class="lbl" for="yswipe-pei">Layer Display</label>
<select id="yswipe-pei" onchange="updateSplit()" aria-describedby="yswipe-hint">
<option value="PEI_original">PEI Original (CDI·IDI·LDI·PDI)</option>
<option value="PEI_new">PEI New (RSI·GSI·BI·PTAL)</option>
<option value="PEI_combined">PEI Combined (All 8)</option>
<optgroup label="Original Indices">
<option value="CDI">Commercial Density (CDI)</option>
<option value="IDI">Intersection Density (IDI)</option>
<option value="LDI">Land Use Diversity (LDI)</option>
<option value="PDI">Population Density (PDI)</option>
</optgroup>
<optgroup label="New Indices">
<option value="RSI">Road Safety (RSI)</option>
<option value="RSI_new">New Road Safety (RSI_new)</option>
<option value="GSI">Green Space (GSI)</option>
<option value="BI">Bike Infrastructure (BI)</option>
<option value="PTAL">Public Transit Access (PTAL)</option>
</optgroup>
</select>
<label class="sub-lbl" for="left-yr">Left Year</label>
<select id="left-yr" onchange="updateSplit()" aria-describedby="yswipe-hint">
<option value="2013">2013</option>
<option value="2017">2017</option>
<option value="2022">2022</option>
</select>
<label class="sub-lbl" for="right-yr">Right Year</label>
<select id="right-yr" onchange="updateSplit()" aria-describedby="yswipe-hint">
<option value="2022">2022</option>
<option value="2017">2017</option>
<option value="2013">2013</option>
</select>
<p class="hint" id="yswipe-hint" style="margin-top:6px">Drag the divider to compare years side by side at
the same location.</p>
</div>
<!-- BASEMAP -->
<div class="sec" role="group" aria-labelledby="lbl-theme" aria-describedby="theme-hint">
<div class="lbl" id="lbl-theme">Theme + Basemap</div>
<div class="br">
<button class="btn" id="b-auto" aria-pressed="false" title="Sync theme with system preference"
onclick="setMapTheme('auto')">Auto</button>
<button class="btn on" id="b-light" aria-pressed="true" title="Use light theme and basemap"
onclick="setMapTheme('light')">Light</button>
<button class="btn" id="b-dark" aria-pressed="false" title="Use dark theme and basemap"
onclick="setMapTheme('dark')">Dark</button>
</div>
<div class="br" style="margin-top:4px">
<button class="btn" id="b-satellite" aria-pressed="false" title="Satellite basemap"
onclick="setBase('satellite')">Sat</button>
<button class="btn" id="b-streets" aria-pressed="false" title="Street basemap"
onclick="setBase('streets')">Streets</button>
</div>
<p class="hint" id="theme-hint">Auto, Light, and Dark sync the app theme and basemap together.</p>
</div>
<!-- OPACITY -->
<div class="sec">
<label class="lbl" for="opa">Layer Opacity</label>
<div class="srow">
<input type="range" id="opa" min="0" max="100" value="80" oninput="setOpacity(this.value)">
<output for="opa" class="sv" id="opa-v">80%</output>
</div>
</div>
</div>
<div id="sb-backdrop" aria-hidden="true"></div>
<!-- MAP -->
<div id="mw" role="main">
<button id="sb-toggle" type="button" title="Open controls" aria-controls="sb"
aria-expanded="false">Controls</button>
<button id="reset-view" type="button" title="Reset map view (Press R)">Reset View</button>
<div id="ld" role="status" aria-live="polite">
<div class="spin"></div>
<p>Loading PEI tileset data…</p>
</div>
<div id="map"></div>
<div id="cmp">
<div id="before-map"></div>
<div id="after-map"></div>
</div>
<div class="fp" id="stats" role="region" aria-labelledby="stats-title">
<div class="pt" id="stats-title">Visible Tracts</div>
<div class="stats-note" id="stats-note">Current viewport</div>
<div class="sr"><span class="sk">Count</span><span class="sv2" id="s-n">—</span></div>
<div class="sr"><span class="sk">Mean</span><span class="sv2" id="s-mean">—</span></div>
<div class="sr"><span class="sk">Min</span><span class="sv2" id="s-min">—</span></div>
<div class="sr"><span class="sk">Max</span><span class="sv2" id="s-max">—</span></div>
</div>
<div class="fp" id="legend" aria-hidden="true">
<div class="pt" id="leg-t">PEI Original</div>
<div class="lb" id="leg-b"></div>
<div class="ll" id="leg-l"><span>0.0</span><span>0.5</span><span>1.0</span></div>
</div>
</div>
<dialog id="info-modal" aria-labelledby="info-modal-title" style="padding: 24px; border: none; border-radius: 12px; max-width: 480px; box-shadow: var(--shadow-lg); background: var(--panel); color: var(--txt); font-family: inherit;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--bdr); padding-bottom: 10px; margin-bottom: 16px;">
<h2 id="info-modal-title" style="margin: 0; font-size: 1.25rem;">About the PEI Dashboard</h2>
<button class="dialog-close" aria-label="Close dialog" title="Close dialog (Esc)" onclick="this.closest('dialog').close()">×</button>
</div>
<div style="font-size: 0.95rem; line-height: 1.5;">
<p style="margin-top: 0;">The <strong>Pedestrian Environment Index (PEI)</strong> is a nationwide metric designed to evaluate the walkability and safety of pedestrian infrastructure across the United States.</p>
<p>This interactive dashboard visualizes eight core built environment indices:</p>
<ul style="padding-left: 20px; margin-bottom: 16px;">
<li>Commercial Density & Intersection Density</li>
<li>Land Use Diversity & Population Density</li>
<li>Road Safety (RSI)</li>
<li>Green Space & Bike Infrastructure</li>
<li>Public Transit Access (PTAL)</li>
</ul>
<p>Use the swipe tools and layer selectors to track structural changes across 2013, 2017, and 2022.</p>
<p><em>More features are to come, including demographic data overlays and additional timeline years!</em></p>
<p style="margin-bottom: 16px;">For more information on how each index was calculated, please visit: <a href="https://vip-smur.github.io/25fa-mobility/" target="_blank" rel="noopener noreferrer" style="color: var(--acc);">https://vip-smur.github.io/25fa-mobility/</a></p>
<h3 style="font-size: 1rem; margin-bottom: 8px;">Keyboard Shortcuts</h3>
<ul class="kbd-list" style="padding-left: 0; margin-bottom: 0; list-style-type: none;">
<li><kbd>?</kbd> Show this info dialog</li>
<li><kbd>/</kbd> Search location</li>
<li><kbd>R</kbd> Reset map view</li>
<li><kbd>Esc</kbd> Close dialogs or controls</li>
</ul>
</div>
<div style="margin-top: 24px; text-align: right;">
<button class="btn on" style="padding: 6px 14px; font-weight: 500;" onclick="this.closest('dialog').close()">Got it</button>
</div>
</dialog>
<script type="module" src="/src/main.js"></script>
</body>
</html>