-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.html
More file actions
2867 lines (2595 loc) · 124 KB
/
map.html
File metadata and controls
2867 lines (2595 loc) · 124 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" />
<title>CMRPC Housing and Transportation Map</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Mapbox GL JS -->
<script src="https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.css" rel="stylesheet" />
<!-- Material UI icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Roboto font -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@700&display=swap" rel="stylesheet">
<style>
.material-icons-outlined {
font-size: 1.25rem;
width: 1.25rem;
height: 1.25rem;
}
html {
scroll-behavior: smooth;
}
body {
font-display: swap;
margin: 0;
font-family: 'Roboto', sans-serif;
}
#map {
width: 100%;
height: 100%;
}
.mapboxgl-popup {
max-width: 250px;
font-family: 'Roboto', sans-serif;
font-size: 0.875rem;
}
.mapboxgl-popup-content {
background: white;
border-radius: 0.5rem;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 1rem;
color: #1f2937;
}
.mapboxgl-popup-close-button {
display: none;
}
.popup-header {
font-family: 'Roboto Condensed', sans-serif;
font-weight: 700;
margin-bottom: 0.5rem;
}
#layer-select option,
#layer-select optgroup {
padding-left: 0;
margin-left: 0;
}
#layer-select optgroup option {
padding-left: 0;
}
</style>
</head>
<body class="overflow-hidden">
<div class="flex h-screen w-screen">
<!-- Sidebar -->
<div id="sidebar" class="w-80 bg-white border-r border-gray-300 shadow-xl p-4 overflow-y-auto z-10">
<div class="flex flex-col h-full">
<h2 id="map-title" class="text-xl font-semibold mb-5">Central Massachusetts Regional Housing and Transportation Study</h2>
<div class="overflow-y-auto flex-grow">
<!-- Data layer selector -->
<div class="mb-4 -ml-3 relative">
<div class="absolute left-3 top-1/2 transform -translate-y-1/2 pointer-events-none">
<svg class="w-4 h-4 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</div>
<select id="layer-select" class="w-full bg-white rounded pl-9 pr-8 py-2 text-sm focus:outline-none appearance-none border-0" style="box-shadow: none;">
<option value="" selected>Select data layer</option>
<option value="blank" hidden></option>
<optgroup label="Housing and People">
<option value="ctysds:pctHH">Recent growth (change in households, 2015-2023)</option>
<option value="tracts:medIncome">Median annual household income</option>
<option value="zip:currentZHVI">Typical home price by zip code (2025)</option>
<option value="zip:chZHVI">Change in typical home price by zip code (2020-2025)</option>
<option value="tracts:pctCostBurdenedOwners">Percent of homeowners cost burdened</option>
<option value="tracts:pctCostBurdenedRenters">Percent of renters cost burdened</option>
<option value="tracts:rdAge">Displacement risk of seniors</option>
<option value="tracts:rdRace">Displacement risk of non-white populations</option>
<option value="parcels:landuse">Land use (property class)</option>
<option value="parcels:density">Actual residential density (units per acre)</option>
<option value="tracts:mva">Neighborhood conditions</option>
</optgroup>
<optgroup label="Transportation">
<option value="bg:transport-diversity">Transportation diversity</option>
</optgroup>
<optgroup label="Cost Analysis">
<option value="bg:costs-ownership">Monthly ownership costs</option>
<option value="bg:costs-rental">Monthly rental costs</option>
<option value="bg:costs-transport">Average household monthly transportation costs</option>
<option value="bg:costs-HT-owner">Monthly housing + transportation costs (homeowners)</option>
<option value="bg:costs-HT">Monthly housing + transportation costs (renters)</option>
</optgroup>
<optgroup label="Illustrative Personas">
<option value="bg:costs-2veh-owner">Persona: Costs for a family of 3</option>
</optgroup>
<optgroup label="Suitability Analysis">
<option value="buildable:land">Land without environmental constraints</option>
</optgroup>
<optgroup label="Other">
<option value="admin:tracts">Massachusetts tracts</option>
</optgroup>
</select>
</div>
<!-- Legend container -->
<div id="legend" class="mt-4 pb-4 hidden">
<h3 id="legend-title" class="font-medium mb-2 text-black"></h3>
<div id="legend-content" class="space-y-1 text-sm text-black mb-2">
</div>
<button id="layer-info" class="flex items-center text-sm text-black hover:text-gray-700 mt-4">
<span class="material-icons text-base mr-1">info</span>
About this layer
</button>
<div id="layer-description" class="mt-1 text-xs text-black leading-snug hidden">
</div>
</div>
</div>
<!-- Overlays section -->
<div id="overlay-wrapper" class="border-t border-gray-300 w-full mt-auto pt-3">
<button
id="overlay-toggle"
class="w-full pl-0 pr-2 py-2 flex items-center justify-between bg-white hover:bg-gray-100 text-sm font-medium rounded"
>
<span class="flex items-center gap-1">
<span class="material-icons align-text-bottom">layers</span>
Overlays
</span>
<svg id="overlay-arrow" class="w-4 h-4 transform transition-transform" xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</button>
</div>
<!-- Basemap toggle section -->
<div id="basemap-wrapper" class="border-t border-gray-300 w-full pt-3">
<button
id="basemap-toggle"
class="w-full pl-0 pr-2 py-2 flex items-center justify-between bg-white hover:bg-gray-100 text-sm font-medium rounded"
>
<span class="flex items-center gap-1">
<span class="material-icons align-text-bottom">map</span>
Basemap
</span>
<svg id="basemap-arrow" class="w-4 h-4 transform transition-transform" xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
<!-- Basemap options -->
<div id="basemap-settings" class="hidden mt-2 space-y-3 text-sm text-black">
<div id="basemap-style-thumbnails" class="flex gap-2" style="font-family: 'Roboto', sans-serif;">
<button data-style="gray" class="flex-1 border border-white rounded p-1 hover:border-gray-400">
<div class="aspect-video bg-gray-100 rounded text-xs flex items-center justify-center">Gray</div>
</button>
<button data-style="satellite" class="flex-1 border border-white rounded p-1 hover:border-gray-400">
<div class="aspect-video bg-gray-100 rounded text-xs flex items-center justify-center">Aerial</div>
</button>
<button data-style="lightSatellite" class="flex-1 border border-white rounded p-1 hover:border-gray-400">
<div class="aspect-video bg-gray-100 rounded text-xs flex flex-col items-center justify-center leading-tight">
<span>Light</span>
<span>Aerial</span>
</div>
</button>
</div>
</div>
</div>
<!-- Community Scale Logo -->
<div class="border-t border-gray-300 w-full pt-3 mt-3">
<a href="https://communityscale.io" target="_blank" rel="noopener noreferrer" class="flex items-center gap-2 hover:opacity-75 transition-opacity">
<div class="bg-black rounded p-1.5 shadow-sm">
<img src="https://communityscale.io/wp-content/uploads/2024/01/white-on-black-with-edges-150x150.png"
alt="CommunityScale logo"
class="h-6 w-6">
</div>
<span class="font-bold text-black" style="font-family: 'Roboto Condensed', sans-serif;">CommunityScale</span>
</a>
</div>
</div>
</div>
<!-- Overlay Sidebar (slides out from right of main sidebar) -->
<div id="overlay-sidebar" class="w-64 bg-white border-r border-gray-300 shadow-xl p-4 overflow-y-auto z-10 transition-all duration-300" style="height: 100vh; position: fixed; left: -256px;">
<h3 class="text-lg font-semibold mb-4">Overlays</h3>
<!-- Boundaries Section -->
<div class="text-xs font-semibold text-gray-600 uppercase tracking-wide mt-2 mb-2">Boundaries</div>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="towns-outline" checked/>
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Town boundaries</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="subregion-central" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Central subregion</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="subregion-north" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>North subregion</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="subregion-northeast" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Northeast subregion</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="subregion-west" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>West subregion</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="subregion-southwest" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Southwest subregion</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="subregion-southeast" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Southeast subregion</span>
</label>
<!-- Transportation Section -->
<div class="text-xs font-semibold text-gray-600 uppercase tracking-wide mt-3 mb-2">Transportation</div>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="bus-stops-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Bus stops</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="train-stops-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Train stops</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="fair-ped-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Fair pedestrian access</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="good-ped-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Good pedestrian access</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="fair-transit-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Fair transit access</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="good-transit-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Good transit access</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="transit-diversity-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Transportation diversity</span>
</label>
<!-- Zoning Section -->
<div class="text-xs font-semibold text-gray-600 uppercase tracking-wide mt-3 mb-2">Zoning</div>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="mf-byright-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Multifamily by right</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="mf-specialpermit-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Multifamily by special permit</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="exceeds-capacity-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Exceeds development capacity</span>
</label>
<label class="flex items-center gap-2 text-sm text-gray-700 mb-2">
<div class="relative">
<input type="checkbox" class="sr-only overlay-toggle peer" value="excess-capacity-layer" />
<div class="w-6 h-3.5 bg-gray-300 rounded-full peer-checked:bg-gray-600 transition-colors"></div>
<div class="absolute top-[2px] left-[2px] w-2.5 h-2.5 bg-white border border-gray-400 rounded-full transition-transform peer-checked:translate-x-[10px]"></div>
</div>
<span>Has excess development capacity</span>
</label>
</div>
<!-- Map container -->
<div id="map" class="flex-grow relative">
<!-- Map controls -->
<div class="absolute top-4 right-4 flex flex-col gap-2 z-10">
<button id="zoom-in" class="bg-white hover:bg-gray-100 rounded shadow-lg w-10 h-10 flex items-center justify-center text-gray-700 font-bold text-xl border border-gray-300">
+
</button>
<button id="zoom-out" class="bg-white hover:bg-gray-100 rounded shadow-lg w-10 h-10 flex items-center justify-center text-gray-700 font-bold text-xl border border-gray-300">
</button>
<button id="reset-extent" class="bg-white hover:bg-gray-100 rounded shadow-lg w-10 h-10 flex items-center justify-center border border-gray-300" title="Reset to region extent">
<span class="material-icons text-black">refresh</span>
</button>
</div>
</div>
</div>
<script>
// ============================================
// CONFIGURATION
// ============================================
const REGION_NAME = 'Central Massachusetts';
const INITIAL_LOC = [-71.81, 42.21];
const INITIAL_ZOOM = 10;
// CMRPC region communities
const regionOfInterest = [
'BARRE', 'BOYLSTON', 'BROOKFIELD', 'BERLIN', 'BLACKSTONE', 'DUDLEY',
'CHARLTON', 'DOUGLAS', 'EAST BROOKFIELD', 'HARDWICK', 'MILLVILLE',
'NORTH BROOKFIELD', 'OXFORD', 'RUTLAND', 'SOUTHBRIDGE', 'SPENCER',
'STURBRIDGE', 'UXBRIDGE', 'WARREN', 'WEBSTER', 'WEST BROOKFIELD',
'AUBURN', 'GRAFTON', 'LEICESTER', 'HOLDEN', 'HOPEDALE', 'MILLBURY',
'MENDON', 'NEW BRAINTREE', 'PRINCETON', 'NORTHBOROUGH', 'NORTHBRIDGE',
'OAKHAM', 'PAXTON', 'SHREWSBURY', 'SUTTON', 'UPTON', 'WEST BOYLSTON',
'WESTBOROUGH', 'WORCESTER'
];
// Mapbox access token
mapboxgl.accessToken = 'pk.eyJ1IjoiY29tbXVuaXR5c2NhbGUiLCJhIjoiY21hZ3Y4azlmMDU5YTJqb2NqbzRsa3psbSJ9.eJlBVHcMSB88Czl3ti2i5g';
// Basemap styles
const BASEMAP_STYLES = {
gray: 'mapbox://styles/communityscale/cmgicidwh007k01qdauae93b0',
satellite: 'mapbox://styles/communityscale/cmgidsjne002c01qne3nf930s',
lightSatellite: 'mapbox://styles/communityscale/cmgidu19b00n301sb0jcihsuk'
};
// Tileset IDs
const TILESETS = {
tracts: 'mapbox://communityscale.tracts-2020',
parcels: 'mapbox://communityscale.csy6z5wg',
zipcodes: 'mapbox://emtzot01.963cu3b9',
towns: 'mapbox://emtzot01.4s34saee',
ctysds: 'mapbox://emtzot01.7fsgy5ln'
};
// Color palettes
const medIncomePalette = ['#BFD7FF', '#9BB1FF', '#8795F3', '#4956C5', '#071A43'];
const affordabilityPalette = ['#82ac21', '#fff290', '#ecd731'];
const pricePalette = ['#f1eef6', '#bdc9e1', '#74a9cf', '#2b8cbe', '#045a8d'];
const chPricePalette = ['#ffffcc', '#c2e699', '#78c679', '#31a354', '#006837'];
const hhChangePalette = ['#762a83', '#af8dc3', '#e7d4e8', '#f7f7f7', '#d9f0d3', '#7fbf7b', '#1b7837'];
const riskDisplacementPalette = ['#edf8fb', '#b3cde3', '#8c96c6', '#8856a7', '#810f7c'];
const landUsePalette = [
{ key: "R-L", color: "#fffbd7", label: "Low density residential" },
{ key: "R-M", color: "#fff8bf", label: "Medium density residential" },
{ key: "R-H", color: "#fff17f", label: "High density residential" },
{ key: "R-O", color: "#ffab3c", label: "Other housing" },
{ key: "MU-R", color: "#d899dd", label: "Mixed use with residential" },
{ key: "COMM", color: "#df2d83", label: "Commercial" },
{ key: "GR", color: "#d4f088", label: "Greenspace" },
{ key: "IND", color: "#767676", label: "Industrial" },
{ key: "IMP", color: "#f0f420", label: "Improved land" },
{ key: "DEV-R", color: "#cf820f", label: "Developable as residential"},
{ key: "UND", color: "#d5d5d5", label: "Undevelopable"},
{ key: "EXE", color: "#425A70", label: "Exempt" },
{ key: "UNK", color: "#bdc9e1", label: "Unknown" }
];
const buildablePalette = [
{ key: "noSew Built noExempt", color: "#000000", label: "Existing development" },
{ key: "noSew noBuilt noExempt", color: "#ecd731", label: "Buildable, no sewer" },
{ key: "Sew unBuilt noExempt", color: "#6e79dd", label: "Buildable, sewer" }
];
const mvaPalette = [
{ key: "HDCQ", color: "#7a9232", label: "High demand, competitive quality" },
{ key: "HDKU", color: "#becd5f", label: "High demand, keeping up" },
{ key: "HDNI", color: "#f7fccf", label: "High demand, needs improvement" },
{ key: "OKCQ", color: "#2a6abc", label: "Okay demand, competitive quality" },
{ key: "OKKU", color: "#6ea6ea", label: "Okay demand, keeping up" },
{ key: "OKNI", color: "#c3dbf5", label: "Okay demand, needs improvement" },
{ key: "LDCQ", color: "#a62c7c", label: "Low demand, competitive quality" },
{ key: "LDKU", color: "#d977b8", label: "Low demand, keeping up" },
{ key: "LDNI", color: "#f0c2e1", label: "Low demand, needs improvement" }
];
// Layer source information
const LAYER_INFO = {
'ctysds:pctHH': {
source: 'U.S. Census Bureau, American Community Survey',
description: 'Percent change in households between 2015 and 2023.'
},
'tracts:medIncome': {
source: 'U.S. Census Bureau, American Community Survey 5-Year Estimates (2019-2023)',
description: 'Median annual household income for census tracts.'
},
'zip:currentZHVI': {
source: 'Zillow Home Value Index (ZHVI)',
description: 'Typical home value in 2025. ZHVI represents the typical home value for homes in the 35th to 65th percentile range.'
},
'zip:chZHVI': {
source: 'Zillow Home Value Index (ZHVI)',
description: 'Percent change in typical home values between 2020 and 2025.'
},
'tracts:pctCostBurdenedOwners': {
source: 'U.S. Census Bureau, American Community Survey 5-Year Estimates (2019-2023)',
description: 'Percentage of owner-occupied households that are spending 30% or more of their monthly income on housing costs.'
},
'tracts:pctCostBurdenedRenters': {
source: 'U.S. Census Bureau, American Community Survey 5-Year Estimates (2019-2023)',
description: 'Percentage of renter-occupied households that are spending 30% or more of their monthly income on housing costs.'
},
'tracts:rdAge': {
source: 'Displacement Risk Analysis',
description: 'Risk of displacement for senior populations based on housing costs and demographic factors.'
},
'tracts:rdRace': {
source: 'Displacement Risk Analysis',
description: 'Risk of displacement for non-white populations based on housing costs and demographic factors.'
},
'parcels:landuse': {
source: 'Municipal Assessor Data',
description: 'Property classification by land use type.'
},
'parcels:density': {
source: 'Municipal Assessor Data',
description: 'Actual residential density measured in dwelling units per acre.'
},
'tracts:mva': {
source: 'Market Value Analysis',
description: 'Neighborhood conditions based on market value and demographic indicators.'
},
'bg:transport-diversity': {
source: 'Transportation Diversity Analysis',
description: 'Areas where everyday trips can be completed without a car using walking, biking, or transit.'
},
'bg:costs-ownership': {
source: 'Housing and Transportation Cost Analysis',
description: 'Average monthly costs for homeowners including mortgage, taxes, and utilities.'
},
'bg:costs-rental': {
source: 'Housing and Transportation Cost Analysis',
description: 'Average monthly rental costs including rent and utilities.'
},
'bg:costs-transport': {
source: 'Housing and Transportation Cost Analysis',
description: 'Average household monthly transportation costs.'
},
'bg:costs-HT-owner': {
source: 'Housing and Transportation Cost Analysis',
description: 'Combined monthly housing and transportation costs for homeowners.'
},
'bg:costs-HT': {
source: 'Housing and Transportation Cost Analysis',
description: 'Combined monthly housing and transportation costs for renters.'
},
'bg:costs-2veh-owner': {
source: 'Housing and Transportation Cost Analysis',
description: 'Total monthly costs for a family of 3 with two vehicles.'
},
'buildable:land': {
source: 'Environmental Constraints Analysis',
description: 'Land areas without environmental constraints that may be suitable for development.'
},
'admin:tracts': {
source: 'U.S. Census Bureau',
description: 'Massachusetts census tract boundaries.'
}
};
// Data storage
let currentDataLayer = null;
let currentLayerName = null;
let currentBasemap = 'gray';
let initialRegionBounds = null;
let dataLoaded = {
medIncome: false,
costBurden: false,
displacementRisk: false
};
let costBreaks = {}; // Store calculated quintile breaks for cost layers
// ============================================
// MAP INITIALIZATION
// ============================================
const map = new mapboxgl.Map({
container: 'map',
style: BASEMAP_STYLES[currentBasemap],
center: INITIAL_LOC,
zoom: INITIAL_ZOOM,
maxZoom: 22
});
// Update page title
document.title = REGION_NAME + ' - Housing and Transportation Map';
document.getElementById('map-title').textContent = 'Central Massachusetts Regional Housing and Transportation Study';
// Add error logging
map.on('error', function(e) {
console.error('Map error:', e);
});
map.on('styleimagemissing', function(e) {
console.warn('Style image missing:', e);
});
// ============================================
// MAP LOAD EVENT
// ============================================
map.on('load', function() {
console.log('Map initial load - adding sources');
// Store initial bounds
initialRegionBounds = map.getBounds();
// Add sources from tilesets
map.addSource('tracts-source', {
type: 'vector',
url: TILESETS.tracts,
promoteId: 'GEOID'
});
map.addSource('parcels-source', {
type: 'vector',
url: TILESETS.parcels,
promoteId: 'LOC_ID'
});
map.addSource('zipcodes-source', {
type: 'vector',
url: TILESETS.zipcodes,
promoteId: 'ZCTA5'
});
map.addSource('towns-source', {
type: 'vector',
url: TILESETS.towns,
promoteId: 'TOWN_ID'
});
map.addSource('ctysds-source', {
type: 'vector',
url: TILESETS.ctysds,
promoteId: 'GEOID'
});
// Add GeoJSON sources
map.addSource('bg-costs-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_bg_costs.geojson',
promoteId: 'GEO_ID_clean'
});
map.addSource('bg-transport-diversity-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_bg_transportation_diverse_marg.geojson',
promoteId: 'geoid'
});
map.addSource('buildable-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/buildable6.geojson'
});
map.addSource('communityboundaries-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/communityboundaries.geojson'
});
// Add overlay sources
map.addSource('subregions-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_Tigerlines_Regions_FromCytsds_250820.geojson',
promoteId: 'TOWN_ID'
});
map.addSource('bus-stops-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/bus_stops.geojson'
});
map.addSource('train-stops-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_RailStations_251017.geojson'
});
map.addSource('transit-diversity-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/parcels_transportation_diversity_marg_onlytrue_diss.geojson',
promoteId: 'loc_id'
});
map.addSource('ped-quality-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_ped_quality_dissolved_select_qualities_251020.geojson',
promoteId: 'loc_id'
});
map.addSource('transit-quality-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_transit_quality_dissolved_selected_qualities_251020.geojson',
promoteId: 'loc_id'
});
map.addSource('mf-byright-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_MFByRight_251009.geojson'
});
map.addSource('mf-specialpermit-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_MFBySpecialPermit_SpecialReview_251009.geojson'
});
map.addSource('excess-capacity-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_DissolvedParcels_ExcessCapacity_251017.geojson'
});
map.addSource('exceeds-capacity-source', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/CommunityScale/CMRPC/refs/heads/main/CMRPC_DissolvedParcels_ExceedsCapacity_251017.geojson'
});
console.log('All sources added');
// Find the first symbol layer for proper layer ordering
const layers = map.getStyle().layers;
let firstSymbolId;
for (const layer of layers) {
if (layer.type === 'symbol') {
firstSymbolId = layer.id;
break;
}
}
console.log('First symbol layer ID:', firstSymbolId);
// Add town boundaries layer (only if it doesn't exist)
if (!map.getLayer('towns-outline')) {
try {
map.addLayer({
id: 'towns-outline',
type: 'line',
source: 'towns-source',
'source-layer': 'massachusetts_towns-a8k14v',
paint: {
'line-color': '#1f2937',
'line-width': 1.5
},
filter: ['in', 'TOWN', ...regionOfInterest]
}, firstSymbolId);
console.log('✓ Town boundaries layer added');
} catch (err) {
console.error('Error adding town boundaries:', err);
}
}
// Add town labels layer (only if it doesn't exist)
if (!map.getLayer('town-labels')) {
try {
map.addLayer({
id: 'town-labels',
type: 'symbol',
source: 'communityboundaries-source',
layout: {
'text-field': ['get', 'TOWN'],
'text-font': ['Roboto Regular', 'Arial Unicode MS Bold'],
'text-size': 11,
'text-transform': 'uppercase',
'text-letter-spacing': 0.1,
'visibility': 'visible',
'symbol-placement': 'point',
'text-allow-overlap': false,
'text-optional': true
},
paint: {
'text-color': '#000000',
'text-halo-color': '#ffffff',
'text-halo-width': 1.5
},
minzoom: 9
});
console.log('✓ Town labels layer added');
} catch (err) {
console.error('Error adding town labels:', err);
}
}
// Add overlay layers (all initially hidden)
console.log('Adding overlay layers...');
// Subregion boundaries
const subregions = ['central', 'north', 'northeast', 'west', 'southwest', 'southeast'];
subregions.forEach(region => {
map.addLayer({
id: `subregion-${region}`,
type: 'line',
source: 'subregions-source',
paint: {
'line-color': '#000000',
'line-width': 5
},
layout: {
visibility: 'none'
},
filter: ['==', ['get', 'region'], region.toUpperCase()]
}, firstSymbolId);
});
// Bus stops
map.addLayer({
id: 'bus-stops-layer',
type: 'circle',
source: 'bus-stops-source',
paint: {
'circle-color': '#ff0000',
'circle-radius': [
'interpolate',
['linear'],
['zoom'],
9, 1.5,
12, 3,
15, 5,
18, 8
]
},
layout: {
visibility: 'none'
}
}, firstSymbolId);
// Train stops
map.addLayer({
id: 'train-stops-layer',
type: 'circle',
source: 'train-stops-source',
paint: {
'circle-color': '#ED8B00',
'circle-radius': 3
},
layout: {
visibility: 'none'
},
filter: ['==', ['get', 'C_RAILSTAT'], 'Y']
}, firstSymbolId);
// Pedestrian quality layers
map.addLayer({
id: 'fair-ped-layer',
type: 'fill',
source: 'ped-quality-source',
paint: {
'fill-color': '#c9c744',
'fill-opacity': 0.6
},
layout: {
visibility: 'none'
},
filter: ['==', ['get', 'ped_quality'], 'fair']
}, firstSymbolId);
map.addLayer({
id: 'good-ped-layer',
type: 'fill',
source: 'ped-quality-source',
paint: {
'fill-color': '#89aa42',
'fill-opacity': 0.6
},
layout: {
visibility: 'none'
},
filter: ['==', ['get', 'ped_quality'], 'high']
}, firstSymbolId);
// Transit quality layers
map.addLayer({
id: 'fair-transit-layer',
type: 'fill',
source: 'transit-quality-source',
paint: {
'fill-color': '#6e79dd',
'fill-opacity': 0.6
},
layout: {
visibility: 'none'
},
filter: ['==', ['get', 'transit_quality'], 'fair']
}, firstSymbolId);
map.addLayer({
id: 'good-transit-layer',
type: 'fill',
source: 'transit-quality-source',
paint: {
'fill-color': '#091a3f',
'fill-opacity': 0.6
},
layout: {
visibility: 'none'
},
filter: ['==', ['get', 'transit_quality'], 'high']
}, firstSymbolId);
// Transit diversity layer (fill + outline)
map.addLayer({
id: 'transit-diversity-layer',
type: 'fill',
source: 'transit-diversity-source',
paint: {
'fill-color': '#000000',
'fill-opacity': [
'interpolate',
['linear'],
['zoom'],
0, 0.95,
15, 0.0
]
},
layout: {
visibility: 'none'
}
}, firstSymbolId);
map.addLayer({
id: 'transit-diversity-outline',
type: 'line',
source: 'transit-diversity-source',
paint: {
'line-color': '#000000',
'line-width': 2,
'line-opacity': [
'interpolate',
['linear'],
['zoom'],
13, 0,
14, 1
]
},
layout: {
visibility: 'none'
}
}, firstSymbolId);
// Zoning layers
map.addLayer({
id: 'mf-byright-layer',
type: 'fill',
source: 'mf-byright-source',
paint: {
'fill-color': '#028b57',
'fill-opacity': 0.6
},
layout: {
visibility: 'none'
}
}, firstSymbolId);
map.addLayer({
id: 'mf-specialpermit-layer',
type: 'fill',
source: 'mf-specialpermit-source',
paint: {
'fill-color': '#9e1583',
'fill-opacity': 0.6
},
layout: {
visibility: 'none'
}
}, firstSymbolId);
// Capacity layers
map.addLayer({
id: 'excess-capacity-layer',
type: 'fill',
source: 'excess-capacity-source',
paint: {
'fill-color': '#ecd731',
'fill-opacity': [
'interpolate',
['linear'],
['zoom'],
0, 0.95,
15, 0.3
]
},
layout: {
visibility: 'none'
}
}, firstSymbolId);
map.addLayer({
id: 'excess-capacity-outline',
type: 'line',
source: 'excess-capacity-source',
paint: {
'line-color': '#ecd731',
'line-width': 2.5,
'line-opacity': [
'interpolate',
['linear'],
['zoom'],
14, 0,
15, 1
]
},
layout: {
visibility: 'none'
}