-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
288 lines (237 loc) · 8.32 KB
/
index.js
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
import { data, otherData } from './data.js';
console.log(data)
console.log(otherData)
console.log("Sep 7, 2023");
var aolrcMarkers = []
var accoMarkers = []
var otherMarkers = []
var markerMap;
var MAP_CENTER = [36.222206,-81.646708]
function initMap() {
const dc = new google.maps.LatLng(MAP_CENTER[0], MAP_CENTER[1]);
markerMap = new google.maps.Map(document.getElementById("map"), {
center: dc,
zoom: 8,
});
const iconBaseOld = "https://developers.google.com/maps/documentation/javascript/examples/full/images/";
const iconBase = "https://ssinghjah.github.io/images/"
const icons = {
aolrc: iconBase + "parking.png",
other: iconBase + "metro.png"
}
const iconsOld = {
parking: iconBase + "parking_lot_maps.png",
library: iconBase + "library_maps.png",
info: iconBase + "info-i_maps.png"
};
let path = window.location.hostname.replace(/\//g,''); // Remove all slashes from string
console.log(data);
// addMapMarkers(data, icons, markerMap);
for (var i=0; i < data.values.length; i++)
{
addMarker(data.headers, data.values[i], icons.aolrc, "aolrc");
}
for (var i=0; i < otheroData.values.length; i++)
{
addMarker(otherData.headers, otherData.values[i], icons.other, "other");
}
}
var ToDisplay = ["Name", "Address", "Cost", "Distance to the Mall", "Nearest Exit from VA", "Nearest Exit from MD", "Website", "Navigate_URL"];
var HyperLinks = ["Navigate_URL", "Website"];
function displayNationalMall(mallIcon){
var lat = Number(infoValues[latIndex]);
var lng = Number(infoValues[lngIndex]);
var markerPosition = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
position: markerPosition,
icon: mallIcon,
map: markerMap});
}
function addAOLRCMarkerInfo(infoHeaders, infoValues){
var infoHTML = "<div class='markerPopUp'>";
var numHeaders = infoHeaders.length;
var nameIndex = $.inArray("Name", infoHeaders);
infoHTML += "<strong>" + infoValues[nameIndex] + "</strong><br>"
var addressIndex = $.inArray("Address", infoHeaders);
infoHTML += infoValues[addressIndex] + "<br>"
var websiteIndex = $.inArray("Website", infoHeaders);
infoHTML += '<strong><a href="'+ infoValues[websiteIndex] + '" target="_blank">Website</a></strong>'+ "<br>"
var navIndex = $.inArray("Navigate_URL", infoHeaders);
infoHTML += '<strong><a href = "' + infoValues[navIndex] + '" target="_blank">Navigate</a></strong><br><br>'
return infoHTML
}
function addOtherMarkerInfo(infoHeaders, infoValues){
var infoHTML = "<div class='markerPopUp'>";
var numHeaders = infoHeaders.length;
var nameIndex = $.inArray("Name", infoHeaders);
infoHTML += "<strong>" + infoValues[nameIndex] + "</strong><br>"
var lineIndex = $.inArray("Line", infoHeaders);
infoHTML += "Lines: " + infoValues[lineIndex] + "<br>"
var navIndex = $.inArray("Navigate_URL", infoHeaders);
infoHTML += '<strong><a href = "' + infoValues[navIndex] + '" target="_blank">Navigate</a></strong><br><br>'
return infoHTML
}
function addMarker(infoHeaders, infoValues, layerIcon, markerType){
var uiListID = ""
var markerList = []
var infoHTML = ""
if (markerType == "aolrc")
{
uiListID = "aolrcList"
markerList = aolrcMarkers
infoHTML += addAOLRCMarkerInfo(infoHeaders, infoValues)
}
else if(markerType == "other")
{
uiListID = "otherList"
markerList = otherMarkers
infoHTML += addOtherMarkerInfo(infoHeaders, infoValues)
}
else{
console.log("Error: invalid marker type.")
return;
}
var latIndex = infoHeaders.indexOf("Lat");
var lngIndex = infoHeaders.indexOf("Lng");
var lat = Number(infoValues[latIndex]);
var lng = Number(infoValues[lngIndex]);
var markerPosition = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
position: markerPosition,
icon: layerIcon,
map: markerMap});
var coordInfoWindow = new google.maps.InfoWindow({pixelOffset: new google.maps.Size(0, -25)});
coordInfoWindow.setContent(infoHTML);
coordInfoWindow.setPosition(markerPosition);
markerList.push(marker);
marker.addListener("click", () => {
coordInfoWindow.open({anchor: marker, map});
});
$("#" + uiListID).append(infoHTML + "<br>");
}
function makeInfoWindowEvent(map, infowindow, marker) {
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
const TILE_SIZE = 256;
// The mapping between latitude, longitude and pixels is defined by the web
// mercator projection.
function project(latLng) {
let siny = Math.sin((latLng.lat() * Math.PI) / 180);
// Truncating to 0.9999 effectively limits latitude to 89.189. This is
// about a third of a tile past the edge of the world tile.
siny = Math.min(Math.max(siny, -0.9999), 0.9999);
return new google.maps.Point(
TILE_SIZE * (0.5 + latLng.lng() / 360),
TILE_SIZE * (0.5 - Math.log((1 + siny) / (1 - siny)) / (4 * Math.PI))
);
}
function toggleView(elem){
var current_state = $(elem).data("state");
if (current_state == "map")
{
$(elem).data("state", "list");
$(elem).text("Hide List");
$("#list").removeClass("medium-0");
$("#list").addClass("medium-3");
$("#map").removeClass("medium-12");
$("#map").addClass("medium-9");
$("#list").show();
}
else if(current_state == "list")
{
$(elem).data("state", "map");
$(elem).text("View List");
$("#list").removeClass("medium-3");
$("#list").addClass("medium-0");
$("#list").hide();
$("#map").removeClass("medium-9");
$("#map").addClass("medium-12");
}
}
function toggleMarkerVisibility(allMarkers, markerMap, state){
var numMarkers = allMarkers.length;
for(var i=0; i < numMarkers; i++)
{
if(state == "on")
{
allMarkers[i].setMap(markerMap);
}
else if(state == "off")
{
allMarkers[i].setMap(null);
}
}
}
function toggleLayer(id){
var current_state = $("#" + id).data("state");
if (current_state == "on")
{
$("#" + id).data("state", "off");
$("#" + id).addClass("primary");
$("#" + id).removeClass("secondary");
}
else if(current_state == "off")
{
$("#" + id).data("state", "on");
$("#" + id).addClass("secondary");
$("#" + id).removeClass("primary");
}
}
window.initMap = initMap;
$(function()
{
$("#mapContainer").hide();
$("#guidelinesContainer").show();
$("#volunteerLinksContainer").hide();
$("#resourcesContainer").hide();
$("#mapMarkersToggle").hide()
$("#viewToggle").data("state", "list");
$("#aolrcToggle").data("state", "on");
$("#aolrcToggle").addClass("primary");
$("#accoToggle").data("state", "on");
$("#accoToggle").addClass("primary");
$("#mapToggle").click(function()
{
$("#guidelinesContainer").hide();
$("#resourcesContainer").hide();
$("#mapContainer").show();
$("#volunteerLinksContainer").hide();
$("#mapMarkersToggle").show()
});
$("#advisoryToggle").click(function(){
$("#guidelinesContainer").show();
$("#resourcesContainer").hide();
$("#mapContainer").hide();
$("#volunteerLinksContainer").hide();
$("#mapMarkersToggle").hide()
});
$("#resourcesToggle").click(function(){
$("#guidelinesContainer").hide();
$("#resourcesContainer").show();
$("#mapContainer").hide();
$("#volunteerLinksContainer").hide();
$("#mapMarkersToggle").hide()
});
$("#volunteerLinksToggle").click(function(){
$("#guidelinesContainer").hide();
$("#resourcesContainer").hide();
$("#mapContainer").hide();
$("#volunteerLinksContainer").show();
$("#mapMarkersToggle").hide()
});
$("#viewToggle").click(function(){
toggleView(this);})
$("#aolrcToggle").click(function(){
toggleLayer("aolrcToggle");
toggleMarkerVisibility(aolrcMarkers, markerMap, $(this).data("state"));
});
$("#accoToggle").click(function(){
toggleLayer("accoToggle");
toggleMarkerVisibility(accoMarkers, markerMap, $(this).data("state"));
});
});
$(document).ready(function() {
$(document).foundation();
})