Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
2994 lines (2687 loc) · 117 KB
/
Copy pathindex.html
File metadata and controls
2994 lines (2687 loc) · 117 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
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" href="/logo.png">
<title>South Bronx Studio</title>
<script>
// Use HTML env replacement so values are available to classic inline scripts immediately.
const __readViteHtmlEnv = (value) =>
value && !value.startsWith("%VITE_") ? value : "";
window.MAPTILER_KEY = __readViteHtmlEnv("%VITE_MAPTILER_KEY%");
window.MAPBOX_ACCESS_TOKEN = __readViteHtmlEnv("%VITE_MAPBOX_ACCESS_TOKEN%");
window.ANTHROPIC_API_KEY = __readViteHtmlEnv("%VITE_ANTHROPIC_API_KEY%");
if (!window.MAPTILER_KEY || !window.MAPBOX_ACCESS_TOKEN) {
console.warn("Missing MAPTILER_KEY or MAPBOX_ACCESS_TOKEN in my-webmap/.env");
}
</script>
<link href="https://api.mapbox.com/mapbox-gl-js/v3.6.0/mapbox-gl.css" rel="stylesheet" />
<script src="https://api.mapbox.com/mapbox-gl-js/v3.6.0/mapbox-gl.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<style>
/* Map - Static, always full screen, behind sidebar */
#map {
position: fixed !important;
top: 73px !important;
left: 0 !important;
right: 0 !important;
bottom: 0 !important;
width: 100vw !important;
height: calc(100vh - 73px) !important;
z-index: 0 !important;
}
/* Mobile: adjust map top to account for smaller header */
@media (max-width: 767px) {
#map {
top: 60px !important;
height: calc(100vh - 60px) !important;
}
}
.sidebar{
position: fixed;
top: 73px;
left: 0;
bottom: 0;
width: 420px;
transition: width .22s ease, transform .22s ease;
z-index: 10;
background: white;
}
.sidebar.collapsed{
width: 96px;
}
.sidebar .panel{display:block}
.sidebar.collapsed .panel{display:none}
.sidebar .rail-justify{justify-content:flex-start}
.sidebar.collapsed .brand-text{display:none}
/* Expand bar - extends from top to bottom on left */
.expand-bar{
width: 24px;
background-color: #e5e7eb;
cursor: pointer;
transition: background-color 0.2s ease;
flex-shrink: 0;
height: 100%;
}
.expand-bar:hover{
background-color: #9ca3af;
}
/* Ensure rail buttons have white background with proper width */
.rail-justify{
background-color: white;
min-width: 72px;
flex-shrink: 0;
}
/* Clean popup styling - no black outlines */
.mapboxgl-popup-content{
padding: 0 !important;
border-radius: 12px !important;
box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
border: none !important;
}
.mapboxgl-popup-close-button{
font-size: 20px !important;
padding: 8px !important;
color: #666 !important;
}
.mapboxgl-popup-tip{
border: none !important;
}
/* Mobile-specific styles */
@media (max-width: 767px){
.sidebar{
position:fixed;
left:0;
top: 60px;
bottom:0;
width: 85vw;
max-width: 360px;
z-index:40;
transform:translateX(-100%);
box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}
.sidebar.open{
transform:translateX(0);
}
.sidebar.collapsed {
transform:translateX(-100%);
}
.backdrop{
position:fixed;
inset:0;
background:rgba(0,0,0,.35);
backdrop-filter:saturate(120%) blur(2px);
z-index:30;
display:none;
}
.backdrop.show{
display:block;
}
/* Hide expand bar on mobile */
.expand-bar {
display: none;
}
/* Mobile header adjustments */
header {
padding: 12px 16px !important;
height: 60px;
}
header img {
height: 24px !important;
}
/* Make rail buttons touch-friendly on mobile */
.rail-btn {
width: 48px !important;
height: 48px !important;
min-width: 48px !important;
}
.rail-btn img {
width: 28px !important;
height: 28px !important;
}
/* Mobile typography */
.sidebar .panel {
padding: 16px !important;
font-size: 13px;
}
.sidebar h2 {
font-size: 15px !important;
}
.sidebar h3 {
font-size: 13px !important;
}
.sidebar p, .sidebar li {
font-size: 12px !important;
line-height: 1.6 !important;
}
/* Mobile select dropdown */
#priorityLocationSelect {
font-size: 13px !important;
padding: 10px 12px !important;
}
/* Mobile checkbox styling */
input[type="checkbox"] {
width: 18px !important;
height: 18px !important;
}
}
.debug-panel{
display: none !important;
position:fixed;left:8px;bottom:8px;z-index:9999;
max-width:320px;max-height:40vh;overflow:auto;
background:#fff;border:1px solid #ddd;border-radius:8px;
box-shadow:0 2px 10px rgba(0,0,0,.08);
padding:8px;font:12px system-ui, -apple-system, Segoe UI, Roboto, sans-serif
}
.debug-panel h4{margin:0 0 6px 0;font-size:12px}
/* Disclaimer styling */
.disclaimer__content{
max-height: 470px;
overflow-y: auto;
margin-bottom: 20px;
}
@media (max-width: 767px) {
.disclaimer__content {
max-height: 60vh;
}
}
.disclaimer__item{
margin-bottom: 16px;
}
.disclaimer__item:last-child{
margin-bottom: 0;
}
.disclaimer__item h3{
font-size: 14px;
font-weight: 600;
color: #374151;
margin: 0 0 6px 0;
}
.disclaimer__item p{
font-size: 13px;
line-height: 1.6;
color: #4b5563;
margin: 0;
}
/* Simple PLOS Bar Chart */
.plos-chart-section {
margin-top: 16px;
display: none;
}
.plos-chart-section.active {
display: block;
}
.plos-chart-title {
font-size: 11px;
font-weight: 600;
color: #666;
margin-bottom: 20px;
text-align: center;
}
/* Range Slider */
.plos-slider-container {
position: relative;
height: 30px;
margin-bottom: 20px;
padding: 0 4px;
}
.plos-slider-track {
position: absolute;
top: 13px;
left: 4px;
right: 4px;
height: 4px;
background: #ddd;
border-radius: 2px;
}
.plos-slider-range {
position: absolute;
height: 100%;
background: #4a90e2;
border-radius: 2px;
pointer-events: none;
}
.plos-slider-handle {
position: absolute;
top: 7px;
width: 16px;
height: 16px;
background: #4a90e2;
border: 2px solid white;
border-radius: 50%;
cursor: grab;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
transform: translateX(-8px);
z-index: 10;
}
.plos-slider-handle:active {
cursor: grabbing;
}
.plos-bars-container {
display: flex;
align-items: flex-end;
justify-content: space-between;
height: 120px;
gap: 4px;
padding: 0 4px;
margin-top: 8px;
}
.plos-bar-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
min-width: 0;
}
.plos-bar-column {
width: 100%;
border-radius: 2px 2px 0 0;
transition: opacity 0.2s;
min-height: 2px;
border: 1px solid rgba(0,0,0,0.1);
}
.plos-bar-item.dimmed .plos-bar-column {
opacity: 0.2;
}
.plos-bar-label {
font-size: 10px;
font-weight: 600;
color: #555;
text-align: center;
}
.plos-bar-value {
font-size: 8px;
color: #999;
text-align: center;
line-height: 1.2;
}
/* Map Legends in Sidebar */
.map-legend {
margin-top: 16px;
background: white;
padding: 12px;
border-radius: 6px;
border: 1px solid #e0e0e0;
display: none;
}
.map-legend.active {
display: block;
}
/* Data Source Attribution styling */
.map-legend[id$="Source"] {
background: #f8f9fa;
border-left: 3px solid #4a90e2;
border: 1px solid #e0e0e0;
border-left: 3px solid #4a90e2;
}
.map-legend[id$="Source"] .legend-title {
color: #4a90e2;
}
.map-legend[id$="Source"] p {
font-size: 11px;
color: #555;
line-height: 1.5;
margin: 0;
}
.map-legend[id$="Source"] strong {
color: #2c3e50;
font-weight: 600;
}
.legend-title {
font-size: 12px;
font-weight: 600;
color: #333;
margin-bottom: 10px;
}
.legend-gradient {
height: 20px;
border-radius: 4px;
margin-bottom: 8px;
}
.legend-labels {
display: flex;
justify-content: space-between;
font-size: 10px;
color: #666;
}
.legend-items {
display: flex;
flex-direction: column;
gap: 5px;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
font-size: 10px;
}
.legend-color-box {
width: 24px;
height: 16px;
border-radius: 3px;
border: 1px solid rgba(0,0,0,0.1);
flex-shrink: 0;
}
.legend-label {
color: #333;
font-weight: 500;
flex: 1;
}
.legend-value {
color: #666;
font-size: 9px;
margin-left: auto;
}
/* Mobile menu button */
.mobile-menu-btn {
display: none;
position: fixed;
top: 12px;
left: 16px;
z-index: 50;
width: 40px;
height: 40px;
background: white;
border: 1px solid #e5e7eb;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
cursor: pointer;
align-items: center;
justify-content: center;
}
@media (max-width: 767px) {
.mobile-menu-btn {
display: flex;
}
}
.hamburger {
width: 20px;
height: 14px;
position: relative;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.hamburger span {
display: block;
height: 2px;
width: 100%;
background: #374151;
border-radius: 2px;
transition: all 0.3s ease;
}
.mobile-menu-btn.open .hamburger span:nth-child(1) {
transform: translateY(6px) rotate(45deg);
}
.mobile-menu-btn.open .hamburger span:nth-child(2) {
opacity: 0;
}
.mobile-menu-btn.open .hamburger span:nth-child(3) {
transform: translateY(-6px) rotate(-45deg);
}
/* ── Agent Analyst Panel ───────────────────────────────────────── */
.ai-chip {
padding: 4px 9px; font-size: 10px; border: 1px solid #d1d5db;
border-radius: 20px; background: #f9fafb; color: #374151;
cursor: pointer; transition: background .12s, border-color .12s; white-space: nowrap;
}
.ai-chip:hover { background: #f3f4f6; border-color: #9ca3af; color: #111827; }
.ai-question-input { width:100%; padding:8px 10px; font-size:11px; border:1px solid #d1d5db; border-radius:6px; resize:vertical; min-height:64px; font-family:inherit; line-height:1.5; box-sizing:border-box; }
.ai-question-input:focus { border-color:#232323; box-shadow:0 0 0 2px rgba(99,102,241,.15); outline:none; }
.ai-analyze-btn { width:100%; padding:8px 12px; background:#1a1a1a; color:#fff; border:none; border-radius:6px; font-size:11px; font-weight:600; cursor:pointer; display:flex; align-items:center; justify-content:center; gap:6px; transition:background .15s; }
.ai-analyze-btn:hover:not(:disabled) { background:#374151; }
.ai-analyze-btn:disabled { background:#9ca3af; cursor:not-allowed; }
.ai-clear-btn { padding:5px 10px; background:transparent; border:1px solid #d1d5db; border-radius:6px; font-size:11px; cursor:pointer; color:#6b7280; }
.ai-clear-btn:hover { background:#f3f4f6; }
.ai-spinner { width:12px; height:12px; border:2px solid rgba(255,255,255,.3); border-top-color:#fff; border-radius:50%; animation:ai-spin .6s linear infinite; display:none; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-analyze-btn.loading .ai-spinner { display:block; }
.ai-analyze-btn.loading .ai-btn-text { opacity:.7; }
.ai-response-box { display:none; font-size:11px; color:#374151; line-height:1.6; }
.ai-response-box.active { display:block; }
.ai-section-title { font-size:9px; font-weight:700; color:#94a3b8; text-transform:uppercase; letter-spacing:.5px; margin:10px 0 4px; }
.ai-rec-item { padding:5px 8px; background:#f8fafc; border-left:2px solid #6366f1; border-radius:0 4px 4px 0; margin-bottom:4px; font-size:10px; }
.ai-highlight-legend { display:none; align-items:center; gap:6px; font-size:10px; color:#475569; padding:5px 8px; background:#f8fafc; border-radius:6px; margin-bottom:6px; }
.ai-highlight-legend.active { display:flex; }
.ai-bar-chart { display:none; }
.ai-bar-chart.active { display:block; }
.ai-bar-chart-title { font-size:9px; color:#94a3b8; text-transform:uppercase; letter-spacing:.4px; margin-bottom:6px; font-weight:700; }
.ai-bars-outer { display:flex; gap:3px; align-items:flex-end; height:60px; }
.ai-bar-col { display:flex; flex-direction:column; align-items:center; flex:1; }
.ai-bar-fill { width:100%; background:#cbd5e1; border-radius:2px 2px 0 0; min-height:3px; }
.ai-bar-col.is-peak .ai-bar-fill { background:#f522a4; }
.ai-bar-lbl { font-size:7px; color:#94a3b8; margin-top:2px; }
</style>
</head>
<body class="h-screen w-screen overflow-hidden bg-neutral-50">
<!-- Mobile Menu Button -->
<button class="mobile-menu-btn" id="mobileMenuBtn" aria-label="Toggle menu">
<div class="hamburger">
<span></span>
<span></span>
<span></span>
</div>
</button>
<!-- Backdrop for mobile -->
<div class="backdrop" id="backdrop"></div>
<!-- Header stretched across the top -->
<header class="fixed top-0 left-0 right-0 flex items-center justify-between gap-3 p-4 border-b-2 border-black bg-white z-20">
<div class="flex items-center gap-3">
<div id="brandLogo" class="shrink-0 grid place-items-center h-10 w-10 rounded-lg bg-white text-white font-bold cursor-pointer md:block hidden" title="Collapse/Expand">
<img src="./src/assets/MIT.svg" class="mr-[-40px] scale-[1.3] translate-y-2" > >
</div>
<div class="brand-text flex items-center gap-3">
<img src="./src/assets/SBX.png" class="h-6 md:h-8 md:ml-[55px] md:scale-[1.3]" style="object-fit: contain;"/>
</div>
</div>
<div class="flex items-center">
<img src="./src/assets/People_S.png" class="h-6 md:h-8 md:mr-[175px] md:scale-[1.4]" style="object-fit: contain;"/>
</div>
</header>
<!-- Main content area: sidebar + map -->
<div class="relative h-full w-full overflow-hidden">
<!-- Map - Fixed position, always full screen, behind sidebar -->
<div id="map"></div>
<!-- Sidebar - Fixed position, overlays map -->
<aside id="sidebar" class="sidebar bg-white border-r border-neutral-200 shadow-sm flex">
<!-- Expand/collapse bar - extends to bottom (hidden on mobile) -->
<div class="expand-bar" title="Click to expand/collapse sidebar"></div>
<nav class="rail-justify flex flex-col items-center gap-2 p-3 border-r border-neutral-200" role="tablist" aria-orientation="vertical">
<button class="rail-btn h-10 w-10 rounded-lg border border-neutral-300 bg-white text-sm font-bold aria-selected:bg-[#c0c0c0] aria-selected:text-white flex items-center justify-center" aria-selected="true" data-tab="background" role="tab" aria-controls="background" title="Background"> <img src="./src/assets/home.svg" alt="Background" class="w-8 h-8"></button>
<button class="rail-btn h-10 w-10 rounded-lg border border-neutral-300 bg-white text-sm font-bold aria-selected:bg-[#c0c0c0] aria-selected:text-white flex items-center justify-center" data-tab="traffic" role="tab" aria-controls="traffic" title="Traffic Data"><img src="./src/assets/map.svg" alt="Traffic" class="w-8 h-8"></button>
<button class="rail-btn h-10 w-10 rounded-lg border border-neutral-300 bg-white text-sm font-bold aria-selected:bg-[#c0c0c0] aria-selected:text-white flex items-center justify-center" data-tab="ai_analyst" role="tab" aria-controls="ai_analyst" title="Agent Analyst">
<img src="./src/assets/ai.svg" alt="Agent Analyst" class="w-8 h-8">
</button>
<button class="rail-btn h-10 w-10 rounded-lg border border-neutral-300 bg-white text-sm font-bold aria-selected:bg-[#c0c0c0] aria-selected:text-white flex items-center justify-center" data-tab="intervention" role="tab" aria-controls="intervention" title="Intervention"><img src="./src/assets/pencil.svg" alt="Intervention" class="w-8 h-8"></button>
</nav>
<section class="panel flex-1 overflow-y-auto p-4">
<!-- Background Tab -->
<div id="background" class="tab-content space-y-4 text-xs" role="tabpanel">
<div>
<h2 class="text-sm font-bold mb-2">Background</h2>
<p class="text-justify leading-relaxed">
The South Bronx is shaped by high population density, strong reliance on walking and public transit,
and the close coexistence of residential, industrial, and transportation infrastructure. Despite high
pedestrian demand, many streets remain unsafe or uncomfortable due to fast-moving traffic, limited
pedestrian amenities, and infrastructural barriers such as highways and toll roads. These conditions
restrict access to services, waterfronts, and public space, making pedestrian analysis essential to
identifying spatial inequities and design opportunities.
</p>
</div>
<div>
<h2 class="text-sm font-bold mb-2">Objectives</h2>
<p class="text-justify leading-relaxed">
This studio project analyzes pedestrian movement, traffic, and land use in the South Bronx to inform targeted
urban design strategies. By integrating pedestrian density, transit accessibility, and network
connectivity, the studio identifies priority corridors and underutilized areas for activation. The
goal is to improve walkability, safety, and environmental quality while strengthening connections
between neighborhoods, transit, commercial areas, and the waterfront.
</p>
</div>
</div>
<!-- Traffic Data Tab -->
<div id="traffic" class="tab-content hidden space-y-4 text-xs" role="tabpanel">
<div>
<h2 class="text-sm font-bold mb-3">Traffic Data</h2>
<p class="text-justify leading-relaxed mb-4">
This section provides access to traffic and pedestrian density data for the South Bronx area.
Use the layer controls below to visualize different data types on the map.
</p>
<h3 class="text-xs font-semibold mb-2">Layers</h3>
<ul class="space-y-2">
<li class="flex items-center gap-2">
<input id="cbPeds" type="checkbox" class="h-4 w-4">
<span>Pedestrian Density</span>
</li>
<li class="flex items-center gap-2">
<input id="cbVehicles" type="checkbox" class="h-4 w-4">
<span>Vehicle Density</span>
</li>
<li class="flex items-center gap-2">
<input id="cbPLOS" type="checkbox" class="h-4 w-4">
<span>Pedestrian Level of Service</span>
</li>
</ul>
<!-- Pedestrian Density Legend -->
<div id="pedestrianLegend" class="map-legend">
<div class="legend-title">Pedestrian Density</div>
<div class="legend-gradient" style="background: linear-gradient(to right, #cce5ff, #66afff, #0079ff, #0047b3, #001a66, #000829);"></div>
<div class="legend-labels">
<span>Low (≤1,000)</span>
<span>High (≥100,000)</span>
</div>
</div>
<!-- Vehicle Traffic Legend -->
<div id="vehicleLegend" class="map-legend">
<div class="legend-title">Vehicle Traffic</div>
<div class="legend-gradient" style="background: linear-gradient(to right, #FFF5F2,#FFE0D9,#FFC2B3,#FFA38C,#FF8566,#FF664D,#FF4D33,#FF3319,#E62600,#CC1F00,#991700,#660D00);"></div>
<div class="legend-labels">
<span>Low (≤100)</span>
<span>High (≥1,000)</span>
</div>
</div>
<!-- PLOS Legend -->
<div id="plosLegend" class="map-legend">
<div class="legend-title">Level of Service</div>
<div class="legend-items">
<div class="legend-item">
<div class="legend-color-box" style="background-color: #00CC00;"></div>
<span class="legend-label">A - Excellent</span>
<span class="legend-value">0.0-1.5</span>
</div>
<div class="legend-item">
<div class="legend-color-box" style="background-color: #77CC00;"></div>
<span class="legend-label">B - Good</span>
<span class="legend-value">1.5-2.5</span>
</div>
<div class="legend-item">
<div class="legend-color-box" style="background-color: #CCCC00;"></div>
<span class="legend-label">C - Fair</span>
<span class="legend-value">2.5-3.5</span>
</div>
<div class="legend-item">
<div class="legend-color-box" style="background-color: #FFCC00;"></div>
<span class="legend-label">D - Poor</span>
<span class="legend-value">3.5-4.5</span>
</div>
<div class="legend-item">
<div class="legend-color-box" style="background-color: #FF9900;"></div>
<span class="legend-label">E+ - Very Poor</span>
<span class="legend-value">4.5-5.5</span>
</div>
<div class="legend-item">
<div class="legend-color-box" style="background-color: #FF6600;"></div>
<span class="legend-label">E - Critical</span>
<span class="legend-value">5.5-6.5</span>
</div>
<div class="legend-item">
<div class="legend-color-box" style="background-color: #FF3300;"></div>
<span class="legend-label">F+ - Failing</span>
<span class="legend-value">6.5-10</span>
</div>
<div class="legend-item">
<div class="legend-color-box" style="background-color: #CC0000;"></div>
<span class="legend-label">F - Redesign Required</span>
<span class="legend-value">10.0+</span>
</div>
</div>
</div>
<!-- PLOS Chart Section -->
<div id="plosChartSection" class="plos-chart-section">
<div class="plos-chart-title">PLOS Distribution</div>
<!-- Range Slider -->
<div class="plos-slider-container">
<div class="plos-slider-track">
<div class="plos-slider-range" id="plosSliderRange"></div>
</div>
<div class="plos-slider-handle" id="plosHandleLeft"></div>
<div class="plos-slider-handle" id="plosHandleRight"></div>
</div>
<div class="plos-bars-container" id="plosBarsContainer">
<!-- Bars will be generated here -->
</div>
</div>
<!-- Data Source Attribution Sections -->
<div id="pedestrianSource" class="map-legend">
<div class="legend-title">Data Source</div>
<p>
Pedestrian density data scraped and developed from <strong>NYC Department of City Planning</strong> and <strong>NYC Open Data</strong> datasets. Values represent estimated daily pedestrian volumes based on sidewalk counts and accessibility analysis.
</p>
</div>
<div id="vehicleSource" class="map-legend">
<div class="legend-title">Data Source</div>
<p>
Vehicle traffic density data scraped and developed from <strong>NYC Department of Transportation (DOT)</strong> and <strong>NYC Open Data</strong> traffic count datasets. Values represent average vehicle volumes during peak hours.
</p>
</div>
<div id="plosSource" class="map-legend">
<div class="legend-title">Data Source</div>
<p>
Pedestrian Level of Service (PLOS) calculated using Highway Capacity Manual methodology, incorporating sidewalk width, pedestrian volume, traffic speed, and street conditions data from <strong>NYC Open Data</strong> and field surveys.
</p>
</div>
<div class="mt-4 p-3 bg-gray-50 rounded border border-gray-200">
<p class="text-xs text-gray-600">
<strong>Note:</strong> Check the boxes above to toggle data layers on the map.
Pedestrian density is shown with a color gradient from yellow (low) to dark brown (high density).
</p>
</div>
</div>
</div>
<!-- AI Analyst Tab -->
<div id="ai_analyst" class="tab-content hidden space-y-4 text-xs" role="tabpanel">
<div>
<h2 class="text-sm font-bold mb-3">Agent Analyst</h2>
<p class="text-justify leading-relaxed mb-3">Ask questions about the traffic and pedestrian data. The Agent will analyze the datasets and highlight relevant segments on the map.</p>
<div class="mb-2">
<label class="block font-semibold text-gray-700 mb-1 text-xs">Question</label>
<div style="display:flex;flex-wrap:wrap;gap:5px;margin-bottom:7px;">
<button class="ai-chip" data-q="Which segments have the highest vehicle traffic at peak hour, and what improvements are recommended?">Peak vehicle traffic</button>
<button class="ai-chip" data-q="Which segments have the highest pedestrian density, and what improvements are recommended?">Highest pedestrian density</button>
<button class="ai-chip" data-q="Which segments have the worst PLOS grade, and how can pedestrian level of service be improved?">Worst PLOS grade</button>
<button class="ai-chip" data-q="Analyze all three datasets — vehicle traffic, pedestrian density, and PLOS — and identify the most critical segments.">Full analysis</button>
</div>
<textarea id="aiQuestion" class="ai-question-input" placeholder="e.g. Which lane segments have the highest peak hour vehicle traffic, and what can be improved?"></textarea>
</div>
<div class="flex items-center gap-2 mb-3">
<button id="aiAnalyzeBtn" class="ai-analyze-btn flex-1">
<div class="ai-spinner"></div>
<span class="ai-btn-text">Analyze Map</span>
</button>
<button id="aiClearBtn" class="ai-clear-btn">Clear</button>
</div>
<div id="aiHighlightLegend" class="ai-highlight-legend">
<span style="width:10px;height:10px;border-radius:2px;background:#f522a4;flex-shrink:0;display:inline-block;"></span>
<span id="aiHighlightLegendText"></span>
</div>
<div id="aiResponseBox" class="ai-response-box"></div>
</div>
</div>
<!-- Intervention Tab -->
<div id="intervention" class="tab-content hidden space-y-4 text-xs" role="tabpanel">
<div>
<h2 class="text-sm font-bold mb-3">Intervention Strategies</h2>
<p class="text-justify leading-relaxed mb-4">
Based on pedestrian movement patterns and traffic data analysis, this section outlines
potential intervention strategies for improving walkability and safety in the South Bronx.
</p>
<h3 class="text-xs font-semibold mb-2">Priority Locations</h3>
<p class="text-justify leading-relaxed mb-3">
Select a priority location to view detailed intervention recommendations and design strategies
for improving pedestrian infrastructure and safety.
</p>
<div class="mb-4">
<label for="priorityLocationSelect" class="block text-xs font-medium text-gray-700 mb-2">
Select Location
</label>
<select
id="priorityLocationSelect"
class="w-full px-3 py-2 text-xs border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white"
>
<option value="">-- Choose a location --</option>
<option value="lincoln-ave">Lincoln Avenue</option>
<option value="138-st">138th Street</option>
<option value="134-st">134th Street</option>
<option value="bruckner-blvd">Bruckner Boulevard</option>
<option value="e133-st">E 133rd Street</option>
<option value="132nd-st">132nd Street</option>
</select>
</div>
<!-- Location Details Container (will be populated when location is selected) -->
<div id="locationDetails" class="hidden">
<div class="p-3 bg-blue-50 rounded-lg border border-blue-200 mb-3">
<h4 class="text-xs font-semibold text-blue-900 mb-1" id="locationName"></h4>
<p class="text-xs text-blue-800" id="locationDescription"></p>
</div>
<h3 class="text-xs font-semibold mb-2 mt-3">Recommended Interventions</h3>
<ul id="interventionsList" class="list-disc pl-5 space-y-1 text-xs text-gray-700">
<!-- Will be populated dynamically -->
</ul>
<h3 class="text-xs font-semibold mb-2 mt-3">Design Strategies</h3>
<ul id="strategiesList" class="list-disc pl-5 space-y-1 text-xs text-gray-700">
<!-- Will be populated dynamically -->
</ul>
</div>
<!-- Default message when no location is selected -->
<div id="defaultMessage" class="mt-4 p-3 bg-gray-50 rounded border border-gray-200">
<p class="text-xs text-gray-600">
Select a priority location from the dropdown above to view specific intervention strategies
and design recommendations.
</p>
</div>
</div>
</div>
</section>
</aside>
</div>
<script>
const sidebar = document.getElementById('sidebar');
const brandLogo = document.getElementById('brandLogo');
const expandBar = document.querySelector('.expand-bar');
const mobileMenuBtn = document.getElementById('mobileMenuBtn');
const backdrop = document.getElementById('backdrop');
const saved = localStorage.getItem('sidebar-collapsed');
if (saved === 'true') sidebar.classList.add('collapsed');
// Function to check if mobile
const isMobile = () => window.innerWidth <= 767;
// Function to toggle sidebar
const toggleSidebar = () => {
if (isMobile()) {
// Mobile: toggle open class and backdrop
sidebar.classList.toggle('open');
backdrop.classList.toggle('show');
mobileMenuBtn.classList.toggle('open');
} else {
// Desktop: toggle collapsed class
sidebar.classList.toggle('collapsed');
localStorage.setItem('sidebar-collapsed', sidebar.classList.contains('collapsed'));
}
};
// Click logo to toggle (desktop only)
brandLogo?.addEventListener('click', () => {
if (!isMobile()) toggleSidebar();
});
// Click thin expand bar to toggle (desktop only)
expandBar?.addEventListener('click', () => {
if (!isMobile()) toggleSidebar();
});
// Mobile menu button
mobileMenuBtn?.addEventListener('click', toggleSidebar);
// Click backdrop to close sidebar (mobile only)
backdrop?.addEventListener('click', () => {
if (isMobile()) {
sidebar.classList.remove('open');
backdrop.classList.remove('show');
mobileMenuBtn.classList.remove('open');
}
});
const railBtns = Array.from(document.querySelectorAll('.rail-btn'));
const panels = Array.from(document.querySelectorAll('.tab-content'));
function activateTab(id){
// Auto-expand sidebar when clicking a button
if (!isMobile() && sidebar.classList.contains('collapsed')) {
sidebar.classList.remove('collapsed');
localStorage.setItem('sidebar-collapsed', 'false');
}
if (isMobile() && !sidebar.classList.contains('open')) {
sidebar.classList.add('open');
backdrop.classList.add('show');
mobileMenuBtn.classList.add('open');
}
railBtns.forEach(b => b.setAttribute('aria-selected', String(b.dataset.tab === id)));
panels.forEach(p => p.classList.toggle('hidden', p.id !== id));
}
railBtns.forEach(b => b.addEventListener('click', () => activateTab(b.dataset.tab)));
activateTab('background');
</script>
<!-- Using Mapbox GL JS (supports both Mapbox and MapTiler) -->
<script>
// Minimal debug
const dbg = document.createElement('div');
dbg.className = 'debug-panel';
dbg.innerHTML = '<h4>Map debug</h4><div id="debugLog"></div>';
document.body.appendChild(dbg);
function debugLog(msg){
const el = document.getElementById('debugLog');
const p = document.createElement('div');
p.textContent = `[${new Date().toLocaleTimeString()}] ${msg}`;
el.appendChild(p); el.scrollTop = el.scrollHeight; console.log(msg);
}
// Mapbox access token should be provided through local config or environment
const MAPBOX_ACCESS_TOKEN = window.MAPBOX_ACCESS_TOKEN || '';
mapboxgl.accessToken = MAPBOX_ACCESS_TOKEN;
if (!MAPBOX_ACCESS_TOKEN) {
console.warn('Mapbox access token is missing. Set window.MAPBOX_ACCESS_TOKEN in config.js.');
}
// MapTiler API key should be provided through local config or environment
const MAPTILER_KEY = window.MAPTILER_KEY || '';
const DEFAULT_BASEMAP_STYLE = 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json';
const BASEMAP_STYLE = MAPTILER_KEY
? `https://api.maptiler.com/maps/0199c990-d557-79f4-a316-082733fdc6a6/style.json?key=${MAPTILER_KEY}`
: DEFAULT_BASEMAP_STYLE;
// --- HYBRID LAYER MANAGER (Mapbox Tilesets + MapTiler Basemaps) ---
class HybridLayerManager {
constructor(map){
this.map = map;
this.layers = {};
this.visibility = {};
// Re-add layers when style changes
map.on('styledata', () => {
setTimeout(() => this.rebuild(), 100);
});
}
addTilesetLayer({key, tilesetId, layerId, sourceLayer, type='line', paint={}, layout={}}){
this.layers[key] = {
tilesetId,
layerId,
sourceLayer,
type,
paint: {...paint},
layout: {...layout}
};
this.visibility[key] = true;
this._add(key);
}
_add(key){
const l = this.layers[key];
if (!l) return;
if (!MAPBOX_ACCESS_TOKEN) {
debugLog(`skipping ${key}: MAPBOX_ACCESS_TOKEN is missing`);
return;
}
// Remove existing layer if it exists
if (this.map.getLayer(l.layerId)) {
this.map.removeLayer(l.layerId);
}
// Check if source already exists
const sourceId = `${key}-source`;
if (!this.map.getSource(sourceId)) {
this.map.addSource(sourceId, {
type: 'vector',
url: `mapbox://${l.tilesetId}`
});
}
// Add layer
this.map.addLayer({
id: l.layerId,
type: l.type,
source: sourceId,
'source-layer': l.sourceLayer,
layout: {
...l.layout,
visibility: this.visibility[key] ? 'visible' : 'none'
},
paint: l.paint
});
debugLog(`added tileset layer: ${key} (${l.tilesetId})`);
}
setVisible(key, visible){
const l = this.layers[key];
if (!l || !this.map.getLayer(l.layerId)) return;
this.visibility[key] = visible;
this.map.setLayoutProperty(l.layerId, 'visibility', visible ? 'visible' : 'none');
}