-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
839 lines (814 loc) · 35.5 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>CCPA Alumni Map</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script src='https://npmcdn.com/csv2geojson@latest/csv2geojson.js'></script>
<script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>
<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">
<link href='https://api.mapbox.com/mapbox-assembly/v1.3.0/assembly.min.css' rel='stylesheet'>
<script src='https://api.mapbox.com/mapbox-assembly/v1.3.0/assembly.js'></script>
<script 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">
<link rel="stylesheet" href="style.css">
</head>
<body>
Moved to <a href="https://ccpa-ousd.github.io/alumni-map/">https://ccpa-ousd.github.io/alumni-map/</a>
<!--
<div id="section1-wrapper" class='wrapper'>
<div class="container ">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class='absolute fl my12 mx12 py12 px12 bg-gray-faint rounder border border--gray txt-s '>
<form id='options'>
<h4 class='txt-bold pb3'>School locations:</h4>
<div class='toggle-group align-center'>
<div class='select-container'>
<select class='select select--s'>
<option name='location' value='california' selected>California</option>
<option name='location' value='us'>United States</option>
<option name='location' value='north_america'>North America</option>
<option name='location' value='global'>Global</option>
</select>
<div class='select-arrow'></div>
</div>
</div>
<h4 class='txt-bold pt6'>School groups:</h4>
<label class='switch-container'>
<input type='checkbox' name='uc' checked />
<div class='switch mr6'></div>
UC
</label>
<label class='switch-container'>
<input type='checkbox' name='csu' checked />
<div class='switch mr6'></div>
CSU
</label>
<label class='switch-container'>
<input type='checkbox' name='ccc' checked />
<div class='switch mr6'></div>
CCC
</label>
<label class='switch-container'>
<input type='checkbox' name='hbcu' checked />
<div class='switch mr6'></div>
HBCU
</label>
<h4 class='txt-bold pt12 '>CCPA Alumni:</h4>
<label class='switch-container'>
<input type='checkbox' name='ccpa_2023' checked />
<div class='switch mr6'></div>
2023
</label>
<label class='switch-container'>
<input type='checkbox' name='ccpa_2022' />
<div class='switch mr6'></div>
2022
</label>
<label class='switch-container'>
<input type='checkbox' name='ccpa_staff' checked />
<div class='switch mr6'></div>
CCPA Staff
</label>
<h4 class='txt-bold pt12 '>NCAA:</h4>
<div class='toggle-group mr18'>
<label class='toggle-container'>
<input name='ncaa_d1' type='checkbox' />
<div class='toggle'>D1</div>
</label>
<label class='toggle-container'>
<input name='ncaa_d2' type='checkbox' />
<div class='toggle'>D2</div>
</label>
<label class='toggle-container'>
<input name='ncaa_d3' type='checkbox' />
<div class='toggle'>D3</div>
</label>
</div>
<h4 class='txt-s txt-bold pt12 pb3 '>Transit:</h4>
<div class='toggle-group align-center'>
<div class='select-container'>
<select class='select select--s'>
<option name='transit' value='ac'>AC Transit</option>
<option name='transit' value='ba'>Bay Area Rapid Transit</option>
<option name='transit' value='ct'>Caltrain</option>
<option name='transit' value='am'>Capitol Corridor JPA</option>
<option name='transit' value='ss'>City of South San Francisco</option>
<option name='transit' value='cm'>Commute.org Shuttles</option>
<option name='transit' value='cc'>County Connection</option>
<option name='transit' value='de'>Dumbarton Express</option>
<option name='transit' value='em'>Emery Go-Round</option>
<option name='transit' value='fs'>Fairfield and Suisun Transit</option>
<option name='transit' value='gf'>Golden Gate Ferry</option>
<option name='transit' value='gg'>Golden Gate Transit</option>
<option name='transit' value='wh'>Livermore Amador VTA</option>
<option name='transit' value='ma'>Marin Transit</option>
<option name='transit' value='pe'>Petaluma Transit</option>
<option name='transit' value='rv'>Rio Vista Delta Breeze</option>
<option name='transit' value='sm'>SamTrans</option>
<option name='transit' value='sb'>San Francisco Bay Ferry</option>
<option name='transit' value='si'>SF International Airport</option>
<option name='transit' value='sf'>San Francisco MTA</option>
<option name='transit' value='sr'>Santa Rosa CityBus</option>
<option name='transit' value='st'>SolTrans</option>
<option name='transit' value='so'>Sonoma County Transit</option>
<option name='transit' value='sa'>Sonoma Marin Area RT</option>
<option name='transit' value='ms'>Stanford Marguerite Shuttle</option>
<option name='transit' value='td'>Tideline Water Taxi</option>
<option name='transit' value='3d'>Tri Delta Transit</option>
<option name='transit' value='uc'>Union City Transit</option>
<option name='transit' value='vc'>Vacaville City Coach</option>
<option name='transit' value='vn'>VINE Transit</option>
<option name='transit' value='sc'>VTA</option>
<option name='transit' value='wc'>WestCat (Contra Costa)</option>
</select>
<div class='select-arrow'></div>
</div>
</div>
<h4 class='txt-s txt-bold pt12 pb3 '>Rail transit:</h4>
<label class='switch-container'>
<input type='checkbox' name='bart_stops' checked />
<div class='switch mr6'></div>
BART
</label>
<label class='switch-container'>
<input type='checkbox' name='caltrain_routes' checked />
<div class='switch mr6'></div>
Caltrain routes
</label>
<label class='switch-container'>
<input type='checkbox' name='amtrak_routes' checked />
<div class='switch mr6'></div>
Amtrak routes
</label>
<label class='switch-container'>
<input type='checkbox' name='caltrain_stops' />
<div class='switch mr6'></div>
Caltrain stations
</label>
<label class='switch-container'>
<input type='checkbox' name='amtrak_stops' />
<div class='switch mr6'></div>
Amtrak stations
</label>
</form>
<form id='params'>
<h4 class='txt-s txt-bold pt12 pb3 '>Travel time:</h4>
<div class='toggle-group align-center'>
<div class='select-container'>
<select class='select select--s'>
<option name='profile' value='walking' selected>Walk</option>
<option name='profile' value='cycling'>Bike</option>
<option name='profile' value='driving'>Drive</option>
</select>
<div class='select-arrow'></div>
</div>
<div class='select-container'>
<select class='select select--s'>
<option name='duration' value='30' selected>30 min</option>
<option name='duration' value='45'>45 min</option>
<option name='duration' value='60'>60 min</option>
</select>
<div class='select-arrow'></div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div id="map"></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiZG9tbGV0IiwiYSI6ImNsaTN5MXhseTA0bWMzZHBoNTlnaG1hYmUifQ.9IpTpyptAxhC6ZoUqKCd9w';
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/domlet/cljxrbgx0000c01rac7og3ym6',
center: [-122.219355, 37.783520],
zoom: 8,
projection: 'mercator'
});
datasets = [
{ 'name': 'schools', 'url': 'https://docs.google.com/spreadsheets/d/e/2PACX-1vRtFnRSJ__Rne8FH9igV93l42bsQE6PhFijwoQ4gimr5l5vlQJnljexLXOK4deup-0hLF0B-tDLA77u/pub?gid=1593214570&single=true&output=csv' },
{ 'name': 'people', 'url': 'https://docs.google.com/spreadsheets/d/e/2PACX-1vRtFnRSJ__Rne8FH9igV93l42bsQE6PhFijwoQ4gimr5l5vlQJnljexLXOK4deup-0hLF0B-tDLA77u/pub?gid=435305116&single=true&output=csv' },
]
categories =
{
// School groups
'uc': { 'color': '#002A56', 'outline': 'black', 'source': 'schools' },
'csu': { 'color': '#E61A37', 'outline': 'black', 'source': 'schools' },
'ccc': { 'color': 'blue', 'outline': 'black', 'source': 'schools' },
'hbcu': { 'color': 'aqua', 'outline': 'black', 'source': 'schools' },
'ncaa_d1': { 'color': '#0097D8', 'outline': 'white', 'source': 'schools' },
'ncaa_d2': { 'color': '#0097D8', 'outline': 'white', 'source': 'schools' },
'ncaa_d3': { 'color': '#0097D8', 'outline': 'white', 'source': 'schools' },
// locations
'us': { 'color': '#9B59B6', 'outline': 'black', 'source': 'schools' },
'california': { 'color': '#E67E22', 'outline': 'black', 'source': 'schools' },
'mexico': { 'color': '#2ECC71', 'outline': 'black', 'source': 'schools' },
'canada': { 'color': '#E65722', 'outline': 'black', 'source': 'schools' },
'global': { 'color': '#F2CA27', 'outline': 'black', 'source': 'schools' },
// 'us-non-california-public': { 'color': 'teal', 'outline': 'black', 'source': 'schools' },
// 'us-non-california-private': { 'color': 'orange', 'outline': 'black', 'source': 'schools' },
'ccpa_2023': { 'color': '#006000', 'outline': 'gold', 'source': 'people' }, // green
'ccpa_2022': { 'color': '#006000', 'outline': 'gold', 'source': 'people' }, // green
'ccpa_staff': { 'color': 'gold', 'outline': '#006000', 'source': 'people' }, // green
// Transit
'bart_routes': { 'color': '', 'outline': '', 'source': 'map_style' },
'bart_stops': { 'color': '', 'outline': '', 'source': 'map_style' },
'caltrain_routes': { 'color': '', 'outline': '', 'source': 'map_style' },
'caltrain_stops': { 'color': '', 'outline': '', 'source': 'map_style' },
'amtrak_routes': { 'color': '', 'outline': '', 'source': 'map_style' },
'amtrak_stops': { 'color': '', 'outline': '', 'source': 'map_style' },
}
// Create an array of all the categories above:
let categoryList = [];
for (var key in categories) {
categoryList.push(key)
}
// isochrone start
// Target the params form in the HTML
const params = document.getElementById('params');
// Create variables to use in getIso()
const urlBase = 'https://api.mapbox.com/isochrone/v1/mapbox/';
const lon = -122.1928997670688;
const lat = 37.761674505667884;
let profile = 'walking';
let minutes = 30;
// Create a LngLat object to use in the marker initialization
const lngLat = {
lon: lon,
lat: lat
};
// Create a function that sets up the Isochrone API query then makes a fetch call
async function getIso() {
const query = await fetch(
`${urlBase}${profile}/${lon},${lat}?contours_minutes=${minutes}&denoise=1&polygons=true&access_token=${mapboxgl.accessToken}`,
{ method: 'GET' }
);
console.log('iso api request' + profile + minutes)
const data = await query.json();
// Set the 'iso' source's data to what's returned by the API query
map.getSource('iso').setData(data);
}
options.addEventListener('change', (event) => {
clickedCat = event.target.name
checked = event.target.checked // true or false
// find a layer with a matching name:
if (clickedCat in categories) {
if (checked) {
map.setLayoutProperty(clickedCat, 'visibility', 'visible');
checked = true
console.log(clickedCat + ' is ' + checked)
} else {
map.setLayoutProperty(clickedCat, 'visibility', 'none');
checked = false
console.log(clickedCat + ' is ' + checked)
};
} else {
if (event.target[event.target.selectedIndex].getAttribute('name') === 'location') {
newLocation = event.target[event.target.selectedIndex].value;
console.log('if - changed the newLocation to ' + newLocation)
if (newLocation === 'california') {
map.setLayoutProperty('global', 'visibility', 'none');
map.setLayoutProperty('canada', 'visibility', 'none');
map.setLayoutProperty('mexico', 'visibility', 'none');
map.setLayoutProperty('us', 'visibility', 'none');
map.setLayoutProperty(newLocation, 'visibility', 'visible');
// fit map to california
const bbox = [[-125.467429, 42.421704], [-111.758190, 31.887826]];
map.fitBounds(bbox, {
padding: { top: 10, bottom: 25, left: 50, right: 5 }
});
} else if (newLocation === 'us') {
map.setLayoutProperty('global', 'visibility', 'none');
map.setLayoutProperty('canada', 'visibility', 'none');
map.setLayoutProperty('mexico', 'visibility', 'none');
map.setLayoutProperty(newLocation, 'visibility', 'visible');
// fit map to united states
const bbox = [[-134.883194, 47.272230], [-73.310976, 21.686577]];
map.fitBounds(bbox, {
padding: { top: 10, bottom: 25, left: 50, right: 5 }
});
} else if (newLocation === 'north_america') {
map.setLayoutProperty('global', 'visibility', 'none');
map.setLayoutProperty('canada', 'visibility', 'visible');
map.setLayoutProperty('mexico', 'visibility', 'visible');
map.setLayoutProperty('us', 'visibility', 'visible');
// fit map to north_america
const bbox = [[-169.089758, 72.076309], [-56.576899, 13.783553]];
map.fitBounds(bbox, {
padding: { top: 10, bottom: 25, left: 50, right: 5 }
});
} else if (newLocation === 'global') {
map.setLayoutProperty('canada', 'visibility', 'visible');
map.setLayoutProperty('mexico', 'visibility', 'visible');
map.setLayoutProperty('us', 'visibility', 'visible');
map.setLayoutProperty('global', 'visibility', 'visible');
// fit map to globe
const bbox = [[-162.080036, -55], [176.16456799665184, -51.862338726085824]];
map.fitBounds(bbox, {
padding: { top: 10, bottom: 25, left: 50, right: 5 }
});
}
} else {
// if the event is a new transit selection...
if (event.target[event.target.selectedIndex].getAttribute('name') === 'transit') {
newTransit = event.target[event.target.selectedIndex].value;
console.log(newTransit)
// check if the transit source has been added
// if no, add the geojson source; iterate to create a list of agencies; and add individual layers for each agency
// if yes, change the selected layer to visible (and others invisible)
}
}
};
});
// When a user changes the value of profile or duration by clicking a button,
// change the parameter's value and make the API query again
params.addEventListener('change', (event) => {
if (event.target[event.target.selectedIndex].getAttribute('name') === 'profile') {
profile = event.target[event.target.selectedIndex].value;
console.log('if - changed the profile')
} else if (event.target[event.target.selectedIndex].getAttribute('name') === 'duration') {
minutes = event.target[event.target.selectedIndex].value;
console.log('else - changed the duration')
}
getIso();
});
// isochrone end
// First wait for the map to load!
map.on('load', () => {
map.loadImage('icons/logo_sys_csu_24px_sq.png', (error, image) => {
if (error) throw error;
map.addImage('csu', image);
});
map.loadImage('icons/logo_sys_uc2_24px_sq.png', (error, image) => {
if (error) throw error;
map.addImage('uc', image);
});
map.loadImage('icons/logo-ccc.png', (error, image) => {
if (error) throw error;
map.addImage('ccc', image);
});
map.loadImage('icons/logo-hbcu.png', (error, image) => {
if (error) throw error;
map.addImage('hbcu', image);
});
map.loadImage('icons/logo-ccpa.png', (error, image) => {
if (error) throw error;
map.addImage('ccpa', image);
});
for (let i = 0; i < datasets.length; i++) {
$.ajax({
type: "GET",
url: datasets[i].url,
dataType: "text",
success: function (csvData) {
csv2geojson.csv2geojson(csvData, {
latfield: 'latitude',
lonfield: 'longitude',
delimiter: ','
}, function (err, data) {
if (err || data.features.length === 0) {
console.log('⚠️ csv error!');
// console.log(data);
} else {
console.log("it happened")
console.log(data)
}
map.addSource(datasets[i].name, {
type: 'geojson',
data: data,
});
const people = map.getStyle().sources['people'].data.features
const schools = map.getStyle().sources['schools'].data.features
function forwardGeocoder(query) {
const matchingFeatures = [];
for (const feature of people) {
if (
feature.properties.name
.toLowerCase()
.includes(query.toLowerCase())
) {
feature['place_name'] = `🦁 ${feature.properties.name}`;
feature['center'] = feature.geometry.coordinates;
matchingFeatures.push(feature);
}
}
return matchingFeatures;
}
map.addControl(
new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
localGeocoder: forwardGeocoder,
mapboxgl: mapboxgl
})
);
map.addLayer({
'id': 'ccc',
'type': 'symbol',
'source': 'schools',
'layout': {
'icon-image': 'ccc',
'icon-size': .16,
},
'filter': ['all', ['==', 'system_acronym', 'CCC']],
});
map.addLayer({
'id': 'uc',
'type': 'symbol',
'source': 'schools',
'layout': {
'icon-image': 'uc',
'icon-size': 1,
},
'paint': {
'icon-halo-color': '#fff',
'icon-halo-width': 2
},
'filter': ['all', ['==', 'system_acronym', 'UC']],
});
map.addLayer({
'id': 'csu',
'type': 'symbol',
'source': 'schools',
'layout': {
'icon-image': 'csu',
'icon-size': 1,
},
'filter': ['all', ['==', 'system_acronym', 'CSU']],
});
map.addLayer({
'id': 'hbcu',
'type': 'symbol',
'source': 'schools',
'layout': {
'icon-image': 'hbcu',
'icon-size': .35,
},
'filter': ['all', ['==', 'hbcu', 'TRUE']],
});
map.addLayer({
'id': 'mexico',
'type': 'circle',
'source': 'schools',
'layout': {
'visibility': 'none'
},
'paint': {
'circle-color': categories['mexico'].color,
'circle-stroke-color': categories['mexico'].outline,
'circle-stroke-width': 1,
'circle-radius': 7,
},
'filter': ['all', ['==', 'country', 'MX']],
});
map.addLayer({
'id': 'california',
'type': 'circle',
'source': 'schools',
'paint': {
'circle-color': categories['california'].color,
'circle-stroke-color': categories['california'].outline,
'circle-stroke-width': 1,
'circle-radius': 7,
},
'filter': ['all',
['==', 'state', 'California'],
['!=', 'system_acronym', 'UC'],
['!=', 'system_acronym', 'CSU'],
['!=', 'system_acronym', 'CCC']
],
});
map.addLayer({
'id': 'ncaa_d1',
'type': 'circle',
'source': 'schools',
'layout': {
'visibility': 'none'
},
'paint': {
'circle-color': categories['ncaa_d1'].color,
'circle-stroke-color': categories['ncaa_d1'].outline,
'circle-stroke-width': 1,
'circle-radius': 7,
},
'filter': ['all', ['==', 'ncaa_div', 'D1'],],
});
map.addLayer({
'id': 'ncaa_d2',
'type': 'circle',
'source': 'schools',
'layout': {
'visibility': 'none'
},
'paint': {
'circle-color': categories['ncaa_d2'].color,
'circle-stroke-color': categories['ncaa_d2'].outline,
'circle-stroke-width': 1,
'circle-radius': 7,
},
'filter': ['all', ['==', 'ncaa_div', 'D2'],],
});
map.addLayer({
'id': 'ncaa_d3',
'type': 'circle',
'source': 'schools',
'layout': {
'visibility': 'none'
},
'paint': {
'circle-color': categories['ncaa_d3'].color,
'circle-stroke-color': categories['ncaa_d3'].outline,
'circle-stroke-width': 1,
'circle-radius': 7,
},
'filter': ['all', ['==', 'ncaa_div', 'D3'],],
});
map.addLayer({
'id': 'us',
'type': 'circle',
'source': 'schools',
'layout': {
'visibility': 'none'
},
'paint': {
'circle-color': categories['us'].color,
'circle-stroke-color': categories['us'].outline,
'circle-stroke-width': 1,
'circle-radius': 7,
},
'filter': ['all',
['==', 'country', 'US'],
['!=', 'state', 'California'],
],
});
map.addLayer({
'id': 'canada',
'type': 'circle',
'source': 'schools',
'layout': {
'visibility': 'none'
},
'paint': {
'circle-color': categories['canada'].color,
'circle-stroke-color': categories['canada'].outline,
'circle-stroke-width': 1,
'circle-radius': 7,
},
'filter': ['all', ['==', 'country', 'CA']],
});
map.addLayer({
'id': 'global',
'type': 'circle',
'source': 'schools',
'layout': {
'visibility': 'none'
},
'paint': {
'circle-color': categories['global'].color,
'circle-stroke-color': categories['global'].outline,
'circle-stroke-width': 1,
'circle-radius': 7,
},
'filter': ['all',
['!=', 'country', 'US'],
['!=', 'country', 'MX'],
['!=', 'country', 'CA'],
],
});
// map.addLayer({
// 'id': 'us-non-california-public',
// 'type': 'circle',
// 'source': 'schools',
// 'paint': {
// 'circle-color': categories['us-non-california-public'].color,
// 'circle-stroke-color': categories['us-non-california-public'].outline,
// 'circle-stroke-width': 1,
// 'circle-radius': 7,
// },
// 'filter': ['all',
// ['==', 'country', 'USA'],
// ['!=', 'state', 'CA'],
// ['!=', 'pub_priv', 'Public'],
// ],
// });
// map.addLayer({
// 'id': 'us-non-california-private',
// 'type': 'circle',
// 'source': 'schools',
// 'paint': {
// 'circle-color': categories['us-non-california-private'].color,
// 'circle-stroke-color': categories['us-non-california-private'].outline,
// 'circle-stroke-width': 1,
// 'circle-radius': 7,
// },
// 'filter': ['all',
// ['==', 'country', 'USA'],
// ['!=', 'state', 'CA'],
// ['!=', 'pub_priv', 'Private'],
// ],
// });
map.addLayer({
'id': 'ccpa_2023',
'type': 'symbol',
'source': 'people',
'layout': {
'icon-image': 'ccpa',
'icon-size': .1,
// 'visibility': 'none'
},
'filter': ['all',
['==', 'grad_year', '2023'],
],
});
map.addLayer({
'id': 'ccpa_2022',
'type': 'symbol',
'source': 'people',
'layout': {
'icon-image': 'ccpa',
'icon-size': .1,
'visibility': 'none'
},
'filter': ['all',
['==', 'grad_year', '2022'],
],
});
map.addLayer({
'id': 'ccpa_staff',
'type': 'symbol',
'source': 'people',
'layout': {
'icon-image': 'ccpa',
'icon-size': .1,
// 'visibility': 'none'
},
'filter': ['all',
['==', 'grad_year', 'staff'],
],
});
});
}
});
};
});
map.on('load', () => {
map.addSource('iso', {
type: 'geojson',
data: {
'type': 'FeatureCollection',
'features': []
}
});
map.addLayer(
{
'id': 'isoLayer',
'type': 'fill',
'source': 'iso',
'paint': {
'fill-color': '#FB02C9',
'fill-opacity': .3,
// 'line-width': 2,
}
},
'poi-label'
);
// marker.setLngLat(lngLat).addTo(map); // Add marker at CCPA
getIso(); // API call
});
// inspect a feature on click
map.on('click', ['csu'], (e) => {
const features = map.queryRenderedFeatures(e.point, {
layers: ['csu']
});
});
// When a click event occurs on a feature in
// the ... layer, open a popup at
// the location of the feature, with
// description HTML from its properties.
map.on('click', categoryList, (e) => {
// popup placement
const coordinates = e.features[0].geometry.coordinates.slice();
while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
}
// popup content
let object = JSON.stringify(e.features[0].properties)
let name = e.features[0].properties.name
let website = e.features[0].properties.website
let image = e.features[0].properties.image
let pubPriv = e.features[0].properties.pub_priv
let layer = e.features[0].layer.id
let html = ''
if (layer == 'uc' || layer == 'csu' || layer == 'ccc') {
let location = e.features[0].properties.location
let system_acronym = e.features[0].properties.system_acronym
let system_long = e.features[0].properties.system_long
html = `<a href='${image}' target='_blank'><img src='${image}' class='popup-img' /></a>
<p><strong><a href="${website}" target='_blank'>${name}</a></strong> is a ${pubPriv.toLowerCase()} school located in ${location}. This campus part of the ${system_long} (${system_acronym}) system.`
} else if (layer == 'ccpa_2022' || layer == 'ccpa_2023') {
let school = e.features[0].properties.school_decision
let year = e.features[0].properties.grad_year
html = `<a href='${image}' target='_blank'><img src='${image}' class='popup-img' /></a>
<p><strong>CCPA Graduate:</strong><br>
${name} (<i>Class of ${year}</i>)</p>
<p><strong>School choice:</strong><br>
<a href="${website}" target='_blank'>${school}</a></p>`
} else if (layer == 'ccpa_staff') {
let school = e.features[0].properties.school_decision
let degree = e.features[0].properties.degree
let profile_url = e.features[0].properties.profile_url
let ccpa_role = e.features[0].properties.ccpa_role
html = `<a href='${image}' target='_blank'><img src='${image}' class='popup-img' /></a>
<p><strong>
<a href='${profile_url}' target='_blank'>${name}</a></strong><br>
<em> CCPA ${ccpa_role}</em></p>
<p><strong>School:</strong><br>
<a href="${website}" target='_blank'>${school}</a></p>
<p><strong>Degree or Credential:</strong><br>
${degree}</p>`
} else if (layer == 'hbcu') {
let location = e.features[0].properties.location
let pub_priv = e.features[0].properties.pub_priv
let ncaa_div = e.features[0].properties.ncaa_div
let ncaa_conf = e.features[0].properties.ncaa_conf
let comment = e.features[0].properties.comment
let regionally_accredited = e.features[0].properties.regionally_accredited
let year_founded = e.features[0].properties.year_founded
if (regionally_accredited == "No") {
regionally_accredited = 'non-regionally accredited'
} else {
regionally_accredited = 'regionally accredited'
}
if (ncaa_div != '') {
if (ncaa_div == 'D1') {
ncaa_div = 'Division I'
} else if (ncaa_div == 'D2') {
ncaa_div = 'Division II'
} else {
ncaa_div = 'Division III'
}
ncaa_div_text = `<p><strong>NCAA:</strong> ${ncaa_div} <br>
<a href='https://en.wikipedia.org/wiki/List_of_NCAA_conferences' target='_blank'>${ncaa_conf}</a></p>`
} else {
ncaa_div_text = ''
}
if (comment != '') {
comment_html = `<p><em>${comment}</em></p>`
} else {
comment_html = ''
}
html = `<a href='${image}' target='_blank'><img src='${image}' class='popup-img' /></a>
<p><strong><a href="${website}" target='_blank'>${name}</a></strong> is a ${pubPriv.toLowerCase()} ${regionally_accredited} HBCU school.</p>
<p><strong>Founded:</strong> ${year_founded}</p>
<p><strong>Location:</strong> ${location}</p>${ncaa_div_text}${comment_html}`
} else if (layer == 'amtrak_stops') {
// let name = e.features[0].properties.name
let stationnam = e.features[0].properties.stationnam
let code = e.features[0].properties.code
let address1 = e.features[0].properties.address1
let address2 = e.features[0].properties.address2
let city = e.features[0].properties.city
let STATE = e.features[0].properties.STATE
let stntype = e.features[0].properties.stntype
let statype = e.features[0].properties.statype
html = `<strong> Amtrak ${stntype.toLowerCase()} stop: <br>
<a href='https://amtrakguide.com/stations/amtrak-stations-in-california/' target='_blank'>${stationnam} (${code})</strong></a><br>
${statype}<br>
<strong>Address:</strong> ${address1}, ${city}, ${STATE}`
} else if (layer == 'caltrain_stops') {
let name = e.features[0].properties.stop_name
let stop_id = e.features[0].properties.stop_id
let zone_id = e.features[0].properties.zone_id
html = `<a href='https://caltrain.com/stations-zones' target='_blank'><strong>${name} Station</strong></a><br>
<strong>Stop ID:</strong> ${stop_id}<br>
<strong>Zone:</strong> ${zone_id}`
} else if (layer == 'bart_stops') {
let name = e.features[0].properties.Name
let desc = e.features[0].properties.Description
let website = "https://bart.gov/stations"
html = `<strong><a href="${website}" target='_blank'>${name} BART Station</a></strong><br>${desc}`
} else {
html = `<a href='${image}' target='_blank'><img src='${image}' class='popup-img' /></a><br/>
<p><strong><a href="${website}" target='_blank'>${name}</a></strong>`
}
// popup, yay!
new mapboxgl.Popup()
.setLngLat(coordinates)
.setMaxWidth("20em")
.setHTML(html)
.addTo(map);
});
map.on('mouseenter', categoryList, () => {
map.getCanvas().style.cursor = 'pointer';
});
map.on('mouseleave', categoryList, () => {
map.getCanvas().style.cursor = '';
});
</script>
-->
</body>
</html>