-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
229 lines (217 loc) · 7.92 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
<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content = "initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
body {
background-color:#3362a8;
}
/* Set the size of the div element that contains the map */
#map {
height: 100%; /* The height is 400 pixels h */
}
html, body{
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<h3><center><font size="6"><font face="Verdana"><font color="#9ec3f4"> Find water refill stations nearby</font></center></h3>
<div id="map"></div>
<script>
// Initialize and add the map
var map, infoWindow;
function initMap() {
var locations = [
/*['Water Station ', 40., -74., 27],
['Water Station ', 40., -74., 27],
['Water Station ', 40., -74., 27], */
['Water Station Sony Werblin Recreation Center', 40.519405, -74.460780, 34],
['Water Station Lucy Stone Hall', 40.522148, -74.434856, 33],
['Water Station Louis Brown Athletic Center', 40.525266, -74.441594, 32],
['Water Station Rutgers Business School', 40.523207, -74.440810, 31],
['Water Station Beck Hall', 40.522743, -74.439313, 30],
['Water Station Livingston Student Center', 40.523463, -74.437229, 29],
['Water Station James Disckson Carr Libary', 40.522436, -74.437378, 28],
['Water Station Tillet Hall', 40.521868, -74.436131, 27],
['Water Station ARC', 40.523838, -74.465272, 26],
['Water Station Science and Engineering Resource Center', 40.522816, -74.462809, 25],
['Water Station Busch Dining Hall', 40.522762, -74.457757, 24],
['Water Station Busch Student Center', 40.523277, -74.458541, 23],
['Water Station Hill Center', 40.521849, -74.462216, 22],
['Water Station Physics Lecture Hall', 40.522428, -74.463444, 21],
['Water Station Douglass Student Center', 40.484842, -74.436801, 20],
['Water Station College Hall', 40.486611, -74.437221, 19],
['Water Station Mason Gross School', 40.485373, -74.434666, 18],
['Water Station Hickman Hall', 40.484656, -74.434491, 17],
['Water Station Loree Classroom Building', 40.483396, -74.435384, 16],
['Water Station Neilson Dining Hall', 40.481635, -74.431727, 15],
['Water Station C/D Recreation Center', 40.478588, -74.432685, 14],
['Water Station Cook Student Center', 40.479178, -74.431529, 13],
['Water Station NJ Institute For Food, Nutrition, & Health', 40.479701, -74.435088, 12],
['Water Station Murray Hall', 40.500554, -74.446616, 11],
['Water Station Zimmerli Art Museum', 40.499861, -74.446029, 10],
['Water Station Academic Building West', 40.501955, -74.448376, 9],
['Water Station Academic Building East', 40.502238, -74.447985, 8],
['Water Station Frelinghuysen Hall', 40.503242, -74.448340, 7],
['Water Station Hardenbargh Hall', 40.504838, -74.449972, 6],
['Water Station Alexander Library', 40.505228, -74.452482, 5],
['Water Station CAC Gym', 40.503202, -74.452643, 4],
['Water Station Brower', 40.503620, -74.451667, 3],
['Water Station Scott Hall', 40.499988, -74.447349, 2],
['Water Station CASC', 40.502790, -74.452190, 1]
];
map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(40.5008, 74.4474),
zoom: 17,
styles: [
{elementType: 'geometry', stylers: [{color: '#242f3e'}]},
{elementType: 'labels.text.stroke', stylers: [{color: '#242f3e'}]},
{elementType: 'labels.text.fill', stylers: [{color: '#746855'}]},
{
featureType: 'landscape.man_made',
elementType: 'geometry',
stylers: [{color:'#696969'}]
},
{
featureType: 'landscape.man_made',
elementType: 'geometry.fill',
stylers: [{color:'#36435d'}]
},
{
featureType: 'administrative.locality',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'poi',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'poi.school',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'poi',
elementType: 'labels.icon',
stylers: [{visibility: 'off'}]
},
{
featureType: 'poi.park',
elementType: 'geometry',
stylers: [{color: '#263c3f'}]
},
{
featureType: 'poi.park',
elementType: 'labels.text.fill',
stylers: [{color: '#6b9a76'}]
},
{
featureType: 'road',
elementType: 'geometry',
stylers: [{color: '#38414e'}]
},
{
featureType: 'road',
elementType: 'geometry.stroke',
stylers: [{color: '#212a37'}]
},
{
featureType: 'road',
elementType: 'labels.text.fill',
stylers: [{color: '#9ca5b3'}]
},
{
featureType: 'road.highway',
elementType: 'geometry',
stylers: [{color: '#746855'}]
},
{
featureType: 'road.highway',
elementType: 'geometry.stroke',
stylers: [{color: '#1f2835'}]
},
{
featureType: 'road.highway',
elementType: 'labels.text.fill',
stylers: [{color: '#f3d19c'}]
},
{
featureType: 'transit',
elementType: 'geometry',
stylers: [{color: '#2f3948'}]
},
{
featureType: 'transit.station',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'water',
elementType: 'geometry',
stylers: [{color: '#17263c'}]
},
{
featureType: 'water',
elementType: 'labels.text.fill',
stylers: [{color: '#515c6d'}]
},
{
featureType: 'water',
elementType: 'labels.text.stroke',
stylers: [{color: '#17263c'}]
}
]
});
infoWindow = new google.maps.InfoWindow;
var marker, i;
var image = 'https://image.ibb.co/fAuVtp/waterdrop2_2.png';
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon: image,
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition(pos);
infoWindow.setContent('Current location.');
infoWindow.open(map);
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
infoWindow.open(map);
}
</script>
<script async defer
src="INSERT_API_KEY_HERE">
</script>
</body>
</html>