-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1619 lines (1461 loc) · 65.1 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
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 http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<script src = "https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<style>
#map {
flex-basis: 0;
flex-grow: 4;
}
.container {
width: 40%;
float: left;
margin-left: 1%;
}
#floating-panel {
position: absolute;
top: 75px;
left: 175px;
z-index: 5;
text-align: center;
font-family: "Roboto", "sans-serif";
line-height: 30px;
padding-left: 10px;
}
.google_map iframe{
width:100%;
}
clearfix {
clear: both
}
#location-form {
margin-left: 2.5%;
width: 95%;
padding-top: 8px;
}
#clear #clear-shuttles-btn {
color: gray;
border-left: none;
border-color: lightgray;
}
#directions-panel {
position: absolute;
top: 50px;
left: 2.5%;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
text-align: center;
font-family: "Roboto", "sans-serif";
line-height: 30px;
padding-left: 10px;
float: left;
}
#container {
height: 600px;
display:flex;
}
#sidebar {
flex-basis: 15rem;
flex-grow: 1;
padding-left: 0.5rem;
padding-right: 0.5rem;
max-width: 30rem;
height: 600px;
box-sizing: border-box;
overflow: auto;
}
#directions-sidebar {
flex-basis: 15rem;
flex-grow: 1;
padding: 1rem;
max-width: 30rem;
height: 100%;
box-sizing: border-box;
overflow: auto;
}
#shuttles-sidebar {
flex-grow: 1;
padding: 1rem;
max-width: 30rem;
width: 100px;
height: 100%;
box-sizing: border-box;
overflow: auto;
}
#place-photos {
max-width: auto;
max-height: 225px;
object-fit: cover;
}
.button-group {
padding-bottom: 50px;
}
.btn-group {
color: white;
border: none;
text-align: center;
display: inline;
font-size: 12px;
cursor: pointer;
width: 100%;
}
/* Dropdown Button */
.btn {
background-color: #c8c2c2;
padding: 8px;
font-size: 12px;
border: none;
cursor: pointer;
}
.check-label {
padding: 0px;
margin: 0px;
}
.check-label-shuttle {
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 22px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.check-label-shuttle input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
.checkmark {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: #eee;
}
.check-label-shuttle:hover input ~ .checkmark {
background-color: #ccc;
}
/* When the checkbox is checked, add a blue background */
.check-label-shuttle input:checked ~ .checkmark {
background-color: #2196F3;
}
/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
content: "";
position: absolute;
display: none;
}
.check-label-shuttle input:checked ~ .checkmark:after {
display: block;
}
.check-label-shuttle .checkmark:after {
left: 9px;
top: 5px;
width: 5px;
height: 10px;
border: solid white;
border-width: 0 3px 3px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.btn:hover, .btn:focus {
background-color: #6f6f6f;
}
/* Dropdown button on hover & focus */
.dropbtn:hover, .dropbtn:focus {
background-color: #6f6f6f;
}
.dropdown:hover .dropdown-content {display: block;}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 120px;
box-shadow: 0px 8px 8px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 1px 1px;
text-decoration: none;
display: block;
font-size: 12px;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd;}
/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
.show {display:block;}
@media screen and (max-width: 900px) {
#shuttles-sidebar{
display: none;
}
}
@media screen and (max-width: 1040px) {
#sidebar{
display: none;
}
}
@media screen and (max-width: 1040px) {
#directions-sidebar{
display: none;
}
}
@media screen and (max-width: 1040px) {
#directions-panel{
display: none;
}
}
@media screen and (max-width: 635px) {
#floating-panel{
display: none;
}
}
.route-buttons {
display: inline;
}
#title {
display: flex;
align-items: center; /* Vertical align the elements to the center */
}
#shuttles-header {
margin: 0;
}
#clear-shuttles-btn {
margin-left: auto; /* Push this element to the right */
}
</style>
</head>
<body>
<div id = 'location-form' class="input-group mb-3">
<input id = 'location-input' type="text" class="form-control" placeholder="Search for a place" aria-label="Recipient's username" aria-describedby="basic-addon2">
<div class="input-group-append">
<button id='clear' class="btn btn-outline-secondary" type="button">X</button>
</div>
</div>
<div id="container">
<div class = 'google_map' id="map"></div>
<div id = 'sidebar'>
<img id = "place-photos" src="" width = 100%>
<div class="btn-group">
<button id = 'left-img' type = "submit" class = "btn btn-primary btn-block" style="border-color: #212C65; background-color: #212C65;">Previous Image</button>
<button id = 'right-img' type = "submit" class = "btn btn-primary btn-block" style="border-color: #212C65; background-color: #212C65;">Next Image</button>
</div>
<div class = "card-block" id = "place-name"></div>
<button id = 'directions-button' type = "submit" class = "btn btn-primary btn-block" style="border-color: #212C65; background-color: #212C65;">Get directions</button>
</div>
<div id = 'directions-sidebar'>
<div id = 'route-buttons'>
<div class="dropdown">
<button onclick = "myFunction()" style="background-color: #212C65; color: white" class="dropbtn btn" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Transportation
</button>
<div id = 'transport-drop' class="dropdown-content btn" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" id = 'WALKING' href="#" onclick = "setTransport('WALKING')">Walking</a>
<a class="dropdown-item" id = 'DRIVING' href="#" onclick = "setTransport('DRIVING')">Driving</a>
<a class="dropdown-item" id = 'BICYCLING' href="#" onclick = "setTransport('BICYCLING')">Biking</a>
<a class="dropdown-item" id = 'TRANSIT' href="#" onclick = "setTransport('TRANSIT')">Transit</a>
</div>
</div>
<button class='btn btn-primary' type="button" style="background-color: #212C65; color: white">
<label class = 'check-label'>Show Least Elevation
<input type="checkbox" id='elevation-check'>
<span class="checkmark"></span>
</label>
</button>
</div>
</div>
<div id = 'shuttles-sidebar'>
<div id = 'title'>
<h4 id = 'shuttles-header'>Emory Campus Shuttles</h4>
<button id='clear-shuttles-btn' class="btn btn-outline-secondary" type="button">></button>
</div>
<div id = 'shuttle-checks'>
<label class="check-label-shuttle">A
<input type="checkbox" id = 'A'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">B
<input type="checkbox" id = 'B'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">B Express (BX)
<input type="checkbox" id = 'BX'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle" style = 'display: inline-block;'>C
<input type="checkbox" id = 'C'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">C-Publix
<input type="checkbox" id = 'C-Publix'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">C-Toco Hills
<input type="checkbox" id = 'C-TocoHills'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">D
<input type="checkbox" id = 'D'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">D Express (DX)
<input type="checkbox" id = 'DX'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">E
<input type="checkbox" id = 'E'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">M
<input type="checkbox" id = 'M'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">NPRC
<input type="checkbox" id = 'NPRC'>
<span class="checkmark"></span>
</label>
<label class="check-label-shuttle">Loop
<input type="checkbox" id = 'Loop'>
<span class="checkmark"></span>
</label>
</div>
</div>
</div>
<div id="floating-panel">
<div class="dropdown">
<button class="dropbtn btn" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Markers
</button>
<div id = 'markers-filter' class="dropdown-content" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" id = 'hide-markers' href="#">Hide</a>
<a class="dropdown-item" id = 'show-markers' href="#">Show</a>
<a class="dropdown-item" id = 'delete-markers' href="#">Delete</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn btn" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="background-color: orange">
Food
</button>
<div id = 'food-filter' class="dropdown-content" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" id = 'food-drop' href="#">All Filters</a>
<a class="dropdown-item" id = 'coffee-drop' href="#">Coffee</a>
<a class="dropdown-item" id = 'dooley-drop' href="#">Dooley</a>
<a class="dropdown-item" id = 'meal-swipes-drop' href="#">Meal Swipes</a>
<a class="dropdown-item" id = 'microwave-drop' href="#">Microwave</a>
<a class="dropdown-item" id = 'vegan-drop' href="#">Vegan</a>
<a class="dropdown-item" id = 'vegetarian-drop' href="#">Vegetarian</a>
<a class="dropdown-item" id = 'vending-drop' href="#">Vending Machine</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn btn" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="background-color: mediumpurple">
Study
</button>
<div id = 'study-filter' class="dropdown-content" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" id = 'study-drop' href="#">All Filters</a>
<a class="dropdown-item" id = 'library-drop' href="#">Library</a>
<a class="dropdown-item" id = 'printer-drop' href="#">Printer</a>
<a class="dropdown-item" id = 'private-study-drop' href="#">Private Study Room</a>
<a class="dropdown-item" id = 'whiteboard-drop' href="#">Whiteboard</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn btn" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="background-color: cornflowerblue">
Buildings
</button>
<div id = 'buildings-filter' class="dropdown-content" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" id = 'academic-filter' href="#">Academic</a>
<a class="dropdown-item" id = 'id-filter' href="#">ID Required</a>
<a class="dropdown-item" id = 'residential-filter' href="#">Residential</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn btn" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="background-color: limegreen;">
Campus
</button>
<div id = 'campus-filter' class="dropdown-content" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" id = 'events-filter' href="#">Events</a>
<a class="dropdown-item" id = 'shuttles-button' href="#">Shuttles</a>
</div>
</div>
<button id="current-location-button" class="btn" type="button" style = 'color:white; background-color: #212C65;' aria-haspopup="true" aria-expanded="false">Current Location</button>
</div>
<iframe src="" frameborder="0"></iframe>
</div>
<div class="clearfix"></div>
<script>
async function getData(url='https://emory-maps-backend.herokuapp.com'){
const response = await fetch(url);
const data = response.json();
return data;
}
var map;
var markers = [];
var directionsRenderer;
var elevationDirectionsRenderer;
var directionsService;
var stepDisplay;
var markerArray = [];
var practiceRoute = [];
var directionsStart;
var directionsEnd;
var currentGeometry;
var distances = [];
var place;
var photoNum;
var elevationGains = [];
var elevations = [];
var globalMode;
var pinned = [];
var filterHub;
var shuttleNames = ['A', 'B', 'BX', 'C', 'C-Publix', 'C-TocoHills', 'D', 'DX', 'E', 'M', 'NPRC', 'Loop'];
var edgeCases = [
{
edge: ['WoodPEC', 'George W. Woodruff P.E. Center', 'Woodruff Physical Education Center', 'Woodruff Physical Education Track'],
real: 'George W. Woodruff Physical Education Center'
},
{
edge: ['Harland Cinema', 'Black Student Union', 'AMUC'],
real: 'Alumni Memorial University Center'
},
{
edge: ['School of Medicine'],
real: 'Emory University School of Medicine'
},
{
edge: ['Lullwater'],
real: 'Lullwater Preserve'
},
{
edge: ['White Hall'],
real: 'Goodrich C. White Hall'
},
{
edge: ['Candler Library'],
real: 'Candler Library'
},
{
edge: ['ESC', 'Student Center', 'Dobbs University Center', 'Dobbs Common Table', `Kaldi's Emory Student Center`],
real: 'Emory Student Center'
},
{
edge: ['Cannon'],
real: 'Cannon Chapel'
},
{
edge: ['Jenkins Courtyard', 'Coca-Cola Commons'],
real: '1300 Clifton Rd, Atlanta, Georgia'
},
{
edge: ['Atwood'],
real: 'Atwood Chemistry Center'
},
{
edge: ['Cox Bridge'],
real: 'The Emory Farmers Market'
},
{
edge: ['Woodruff Library'],
real: 'Robert W. Woodruff Library'
},
{
edge: ['fixie', 'Fixie'],
real: 'The Fixie, Eagle Row'
},
{
edge: ['SAAC', 'Emory SAAC (Student Activity & Academic Center)'],
real: 'Student Activity and Academic Center'
},
{
edge: ['Anthropology Building'],
real: 'Emory University Department of Anthropology'
},
{
edge: ['Longstreet-Means Hall'],
real: 'Eagle Hall'
},
{
edge: ['Emerson Hall', 'Cherry Emerson Hall'],
real: 'Cherry Logan Emerson Hall'
},
{
edge: ['Department of Mathematics and Statistics', 'Department of Mathematics and Computer Science'],
real: 'Mathematics and Science Center'
},
{
edge: ['Barnes & Noble @ Emory University', 'Barnes & Noble @ Emory'],
real: 'Oxford Road Building'
},
{
edge: ['Psychology and Interdisciplinary Sciences Bldg', 'PAIS Building', 'Department of Psychology', 'Department of Quantitative Theory and Methods'],
real: 'Psychology and Interdisciplinary Sciences Building'
},
{
edge: ['Department of Visual Arts'],
real: 'Visual Arts Building'
},
{
edge: ['Emory University Department of Sociology'],
real: 'Tarbutton Hall'
},
{
edge: ['Department of Classics'],
real: 'Candler Library'
},
{
edge: ['Program in Linguistics'],
real: 'Modern Languages Building'
}
];
function addMarker(props, iconLink, markerContent, markerName) {
var marker = new google.maps.Marker({
position: props.coords,
map: map,
icon: iconLink,
markerContent: markerContent,
markerName: markerName
});
//check content
if(props.content) {
var infoWindow = new google.maps.InfoWindow({
content: props.content,
maxWidth: 200
});
var infoWindow2 = new google.maps.InfoWindow({
content: props.content,
maxWidth: 200
});
marker.addListener('mouseover', function() {
infoWindow.open(map, marker);
});
marker.addListener('click', function() {
infoWindow2.open(map, marker);
});
marker.addListener('mouseout', function() {
infoWindow.close(map, marker);
});
}
markers.push(marker);
}
function initialize() {
initMap();
initAutocomplete();
}
function initMap() {
geocoder = new google.maps.Geocoder();
//map options
var options = {
zoom: 16,
center:{lat: 33.7971, lng: -84.3222},
clickableIcons: false
}
//new map
map = new google.maps.Map(document.getElementById('map'), options);
setCurrentGeometry();
document.getElementById("show-markers").addEventListener("click", function() {showMarkers(markers);});
document.getElementById("hide-markers").addEventListener("click", function() {hideMarkers(markers);});
document.getElementById("delete-markers").addEventListener("click", function () {deleteMarkers(markers);});
document.getElementById('food-drop').addEventListener('click', function() {applyFilter('food');});
document.getElementById('coffee-drop').addEventListener('click', function() {applyFilter('coffee');});
document.getElementById('dooley-drop').addEventListener('click', function() {applyFilter('dooley');});
document.getElementById('meal-swipes-drop').addEventListener('click', function() {applyFilter('swipes');});
document.getElementById('microwave-drop').addEventListener('click', function() {applyFilter('microwave');});
document.getElementById('vegan-drop').addEventListener('click', function() {applyFilter('vegan');});
document.getElementById('vegetarian-drop').addEventListener('click', function() {applyFilter('vegetarian');});
document.getElementById('vending-drop').addEventListener('click', function() {applyFilter('vending');});
document.getElementById('study-drop').addEventListener('click', function() {applyFilter('study');});
document.getElementById('library-drop').addEventListener('click', function() {applyFilter('library');});
document.getElementById('printer-drop').addEventListener('click', function() {applyFilter('printer');});
document.getElementById('private-study-drop').addEventListener('click', function() {applyFilter('private_study');});
document.getElementById('whiteboard-drop').addEventListener('click', function() {applyFilter('whiteboard');});
document.getElementById('academic-filter').addEventListener('click', function() {applyFilter('academic');});
document.getElementById('id-filter').addEventListener('click', function() {applyFilter('emory id');});
document.getElementById('residential-filter').addEventListener('click', function() {applyFilter('residence');});
document.getElementById('events-filter').addEventListener('click', function() {applyEventsFilter();});
document.getElementById('sidebar').hidden = true;
document.getElementById('directions-button').hidden = true;
document.getElementById('directions-sidebar').hidden = true;
document.getElementById('shuttles-sidebar').hidden = true;
document.getElementById('right-img').addEventListener('click', function() {nextImage(place, 'right-img');});
document.getElementById('left-img').addEventListener('click', function() {nextImage(place, 'left-img');});
document.getElementById('elevation-check').addEventListener('click', function() {displayElevation();});
document.getElementById('shuttles-button').addEventListener('click', function() {showShuttlesSidebar();});
document.getElementById('A').addEventListener('click', function() {displayShuttleStops('A');});
document.getElementById('B').addEventListener('click', function() {displayShuttleStops('B');});
document.getElementById('BX').addEventListener('click', function() {displayShuttleStops('BX');});
document.getElementById('C').addEventListener('click', function() {displayShuttleStops('C');});
document.getElementById('D').addEventListener('click', function() {displayShuttleStops('D');});
document.getElementById('DX').addEventListener('click', function() {displayShuttleStops('DX');});
document.getElementById('E').addEventListener('click', function() {displayShuttleStops('E');});
document.getElementById('M').addEventListener('click', function() {displayShuttleStops('M');});
document.getElementById('NPRC').addEventListener('click', function() {displayShuttleStops('NPRC');});
document.getElementById('C-TocoHills').addEventListener('click', function() {displayShuttleStops('C-TocoHills');});
document.getElementById('C-Publix').addEventListener('click', function() {displayShuttleStops('C-Publix');});
document.getElementById('Loop').addEventListener('click', function() {displayShuttleStops('Loop');});
document.getElementById('clear-shuttles-btn').addEventListener('click', function() {clearShuttlesSidebar();});
document.getElementById('current-location-button').addEventListener('click', function() {
map.setCenter(currentGeometry);
map.setZoom(18);
var currentPosMarker = {
coords:currentGeometry,
content: `(${currentGeometry.lat.toFixed(4)}, ${currentGeometry.lng.toFixed(4)})`,
}
addMarker(currentPosMarker, 'https://maps.google.com/mapfiles/ms/micons/red-dot.png');
});
infoWindow = new google.maps.InfoWindow();
directionsService = new google.maps.DirectionsService();
var rendererOptions = {
map: map
}
directionsRenderer = new google.maps.DirectionsRenderer(rendererOptions);
elevationDirectionsRenderer = new google.maps.DirectionsRenderer(rendererOptions);
directionsRenderer.setPanel(document.getElementById("directions-sidebar"));
stepDisplay = new google.maps.InfoWindow();
globalMode = 'WALKING';
calculateAndDisplayRoute(
directionsRenderer,
directionsService,
markerArray,
stepDisplay,
map,
globalMode
);
}
var locationForm = document.getElementById('location-form');
var clearButton = document.getElementById('clear');
function clearDirections() {
//document.getElementById('location-input').value='';
document.getElementById('sidebar').hidden = true;
document.getElementById('directions-button').hidden = true;
document.getElementById('directions-sidebar').hidden = true;
deleteMarkers(markers);
deleteMarkers(markerArray);
directionsRenderer.setMap(null);
directionsRenderer.setPanel(null);
elevationDirectionsRenderer.setMap(null);
globalMode = 'WALKING';
if (document.getElementById('elevation-check').checked == true) {document.getElementById('elevation-check').checked = false;}
}
//locationForm.addEventListener('submit', geocode);
locationForm.addEventListener('keydown', initAutocomplete);
clearButton.addEventListener('click', function() {clearDirections(); document.getElementById('location-input').value='';});
function myFunction() {
document.getElementById("transport-drop").classList.toggle("show");
}
function displayElevation() {
var checkBox = document.getElementById("elevation-check");
if (checkBox.checked == true){
highlightLeastElevationRoute(elevationDirectionsRenderer, globalMode);
} else {
elevationDirectionsRenderer.setMap(null);
}
}
function displayShuttleStops(elementId) { //doesn't work for multiple filters at a time... smth wrong with pinned array
var auxPinned = [];
var checkBox = document.getElementById(elementId);
if (checkBox.checked == true){
applyShuttleFilter(elementId);
} else {
deleteMarkers(markers);
for (let i = 0; i < pinned.length; i++) {
let stillChecked = false;
var index = 0; //skipping "Shuttles:"
var thisMarkerContent = pinned[i].markerContent;
var shuttle = thisMarkerContent.substring(index, thisMarkerContent.length);
while (index < shuttle.length) {
if (shuttle.indexOf(' ', index) == -1) {
index = shuttle.length;
}
else {
if (document.getElementById(shuttle.substring(index, shuttle.indexOf(' ', index))).checked == true) { //problem here
index = shuttle.length;
var shuttleString = pinned[i].markerContent;
addMarker({
coords: {
lat: pinned[i].position.lat(),
lng: pinned[i].position.lng()
},
content: `<b><font size='3'>${pinned[i].markerName}</font></b><br> <b>Shuttles:</b> ${shuttleString}`
}, 'https://maps.google.com/mapfiles/ms/micons/bus.png', shuttleString, pinned[i].markerName);
auxPinned.push(markers[markers.length - 1]); //smth here, too many markers
index = shuttle.length;
}
else {
index = shuttle.indexOf(' ', index) + 1;
}
}
}
}
pinned = auxPinned;
}
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
/*function geocode(place) {
var location = document.getElementById('location-input').value;
axios.get("https://maps.googleapis.com/maps/api/geocode/json", {
params: {
address: location,
key: "AIzaSyCsklehWRTLY54gug20dY1zByw0JosG-So"
}
})
.then(function(response) {
//log full response
//add marker
//addMarker(location.coords);
//formatted address
var formattedAddress = response.data.results[0].formatted_address;
var formattedAddressOutput = `
<ul class = "list-group">
<li class = "list-group-item"><strong>Address</strong>: ${formattedAddress}</li>
</ul>
`;
//address components
var addressComponents = response.data.results[0].address_components;
var addressComponentsOutput = '<ul class = "list-group">';
addressComponentsOutput += "</ul>"
//geometry
//formatted address
var lat = response.data.results[0].geometry.location.lat.toFixed(4);
var lng = response.data.results[0].geometry.location.lng.toFixed(4);
var geometryOutput = `
<ul class = "list-group">
<li class = "list-group-item"><strong>Coordinates</strong>: (${lat}, ${lng}) </li>
</ul>
`;
})
.catch(function(error){
console.log(error);
})
}
*/
function reverseGeocode() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(getCurrentAddress);
//navigator.geolocation.getCurrentPosition(getCurrentGeometry);
}
}
function getCurrentAddress(position) {
directionsStart = currentGeometry;
/*
axios.get(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${position.coords.latitude},${position.coords.longitude}&location_type=ROOFTOP&result_type=street_address&key=AIzaSyCsklehWRTLY54gug20dY1zByw0JosG-So`)
.then(function(response) {
console.log(response);
if (response.data.results.length == 0) {
directionsStart = currentGeometry;
}
else{
directionsStart = response.data.results[0].formatted_address;
}
console.log(directionsStart);
})
.catch(function(error) {console.log(error);})
*/
}
/*function getCurrentGeometry(position) {
axios.get(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${position.coords.latitude},${position.coords.longitude}&location_type=ROOFTOP&result_type=street_address&key=AIzaSyCsklehWRTLY54gug20dY1zByw0JosG-So`)
.then(function(response) {
//currentGeometry = response.data.results[0].geometry.location;
currentGeometry = {
lat: sessionStorage.getItem('currentLat'),
lng: sessionStorage.getItem('currentLng')
};
console.log(currentGeometry);
})
.catch(function(error) {console.log(error);})
}
*/
var autocomplete;
function initAutocomplete() {
center = {lat: 33.7971, lng: -84.3222};
defaultBounds = {
north: center.lat + 0.05,
south: center.lat -0.05,
east: center.lng + 0.05,
west: center.lng - 0.05,
};
autocomplete = new google.maps.places.Autocomplete(
document.getElementById('location-input'),
{
types: [],
componentRestrictions: {'country': ['US']}, //improves predictions
fields: ['place_id', 'geometry', 'name', 'formatted_phone_number', 'icon', 'photos', 'website', 'formatted_address'],
strictBounds: false,
bounds: defaultBounds,
});
autocomplete.addListener('place_changed', onPlaceChanged);
function onPlaceChanged() {
if (markerArray.length != 0) {clearDirections();}
place = autocomplete.getPlace();
photoNum = 0;
findAllDistances(place.name);
if(!place.geometry) {
//did not select a prediction
document.getElementById('location-input').placeholder = 'Search';
} else {
let text = '';
//display info about valid place
if (place.name) {
text += `<h4>${place.name}</h4><br>`;
}
if (place.formatted_address) {
text += `${place.formatted_address}<br><br>`;
}
text += `${place.geometry.location.lat().toFixed(4)}, ${place.geometry.location.lng().toFixed(4)}<br><br>`;
if (place.formatted_phone_number) {
text += `${place.formatted_phone_number}<br><br>`;
}
if (place.website) {
text += `<a href = ${place.website}>Website</a><br>`;
}
document.getElementById('place-name').innerHTML = `
<ul class = "list-group">
<li class = "list-group-item">${text}</li>
</ul>
`;
if (place.photos) {
var firstPhoto = place.photos[0].getUrl();
document.getElementById(`place-photos`).src = `${firstPhoto}`;
if (place.photos.length > 1) {
document.getElementById('left-img').hidden = false;
document.getElementById('right-img').hidden = false;
}
}
else {
document.getElementById(`place-photos`).src = `https://upload.wikimedia.org/wikipedia/commons/1/11/Greg_Fenves_13879_003.jpg`;
document.getElementById('left-img').hidden = true;
document.getElementById('right-img').hidden = true;
}
document.getElementById('sidebar').hidden = false;
document.getElementById('directions-button').hidden = false;
var newMarker = {
coords:place.geometry.location
}
addMarker(newMarker, 'https://maps.google.com/mapfiles/ms/micons/red-dot.png');
map.setCenter( {
lat: place.geometry.location.lat(),
lng: place.geometry.location.lng()
});
map.setZoom(18);
}
}
}
function setMapOnAll(map, array) {
for (let i = 0; i < array.length; i++) {
array[i].setMap(map);
}
}
// Removes the markers from the map, but keeps them in the array.
function hideMarkers(array) {
setMapOnAll(null, array);
}
// Shows any markers currently in the array.
function showMarkers(array) {
setMapOnAll(map, array);
}