-
Notifications
You must be signed in to change notification settings - Fork 0
/
alummap7.html
255 lines (210 loc) · 8.11 KB
/
alummap7.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
<!DOCTYPE html>
<html>content=
<head>
<meta name="viewport" "initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>KS Alumns</title>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 93%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- <select id="type" onchange="filterMarkers(this.value);">
<option value="">Please select category</option>
<option value="second">second</option>
<option value="car">car</option>
<option value="third">third</option>
</select> -->
<div id="tfheader">
<form id="newsearch" method="get" action="search();">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>
</div>
<div>
<p>Select years to display:</p>
</div>
<div id="buttons">
<label><input name = "Checkbox1" type = "checkbox" value = "1939" onClick = "selectAllChecked();">1939-1954</label>
<label><input name = "Checkbox1" type = "checkbox" value = "1955" onClick = "selectAllChecked();">1955-1959</label>
<label><input name = "Checkbox1" type = "checkbox" value = "1960" onClick = "selectAllChecked();">1960-1964</label>
<label><input name = "Checkbox1" type = "checkbox" value = "1965" onClick = "selectAllChecked();">1965-1969</label>
<label><input name = "Checkbox1" type = "checkbox" value = "1970" onClick = "selectAllChecked();">1970-1974</label>
<label><input name = "Checkbox1" type = "checkbox" value = "1975" onClick = "selectAllChecked();">1975-1979</label>
<label><input name = "Checkbox1" type = "checkbox" value = "1980" onClick = "selectAllChecked();">1980-1984</label>
<label><input name = "Checkbox1" type = "checkbox" value = "1985" onClick = "selectAllChecked();">1985-1989</label>
<label><input name = "Checkbox1" type = "checkbox" value = "1990" onClick = "selectAllChecked();">1990-1994</label>
<label><input name = "Checkbox1" type = "checkbox" value = "1995" onClick = "selectAllChecked();"> 1995-1999</label>
<label><input name = "Checkbox1" type = "checkbox" value = "2000" onClick = "selectAllChecked();">2000-2004</label>
<label><input name = "Checkbox1" type = "checkbox" value = "2005" onClick = "selectAllChecked();">2005-2009</label>
<label><input name = "Checkbox1" type = "checkbox" value = "2010" onClick = "selectAllChecked();">2010-2014</label>
<label><input name = "Checkbox1" type = "checkbox" value = "2015" onClick = "selectAllChecked();">2015-2017</label>
</div>
<script>
function starter(){
class Person{
constructor([first_name,last_name,email, course,graduation_year,latitude, longitude, address]){
this.first_name = first_name;
this.last_name =last_name;
this.email= email;
this.course = course; //string
this.graduation_year = graduation_year;
this.latitude=latitude;
this.longitude=longitude;
this.address = address; //#can store multiple adresses
}
//would it be useful to store previous addresses?
get_name(){
return this.first_name + " " + this.last_name;
}
get_coords(){
return {lat: this.latitude, lng: this.longitude};
}
get_info(){
return "<p>" + this.first_name + ' ' + this.last_name + "<br />" + "Class of " + this.graduation_year + "<br />" + "Course " + this.course + "<br />" + "Contact: " + this.email + "</p>";
}
get_year(){
return this.graduation_year;
}
}
function initMap() {
var myLatLng = {lat: 42.3561172, lng: -71.0972209};
map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: myLatLng
});
}
function setMap(){
for (var i = 0; i < info.length;i++){
if (info[i][5] != 0.0 || info[i][6] != 0.0){
people.push(new Person(info[i]));
}
}
for (var i=0;i<people.length;i++){
var marker = new google.maps.Marker({
position: people[i].get_coords(),
map: map,
category: people[i].get_year()
});
markers.push(marker);
//(function (){
//windows.push(infowindow);
markers[i].addListener('click',function(marker,i){
return function(){
//infowindow.close();
var old = infowindow;
if (old != null) {
old.close()};
infowindow = new google.maps.InfoWindow({
content: people[i].get_info()
});
infowindow.open(map,markers[i]);
}
} (marker,i));
}
markerClusterer = new MarkerClusterer(map,markers, {imagePath:
'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m',
maxZoom: 7,
minimumClusterSize: 3}
);
}
initMap();
setMap();
}
//THIS IS OUTSIDE OF THE FUNCTION STARTER
var selectAllChecked = function(){
var checkedPlace = [];
//Determine which boxes are checked
var allCheckedElem = document.getElementsByName('Checkbox1');
for (var i = 0; i < allCheckedElem.length;i++){
if (allCheckedElem[i].checked == true) {
checkedPlace.push(allCheckedElem[i].value);
}
}
//If none checked
if (checkedPlace.length == 0){
info = JSON.parse(JSON.stringify(data));
usemarkers= []
for (var i = 0; i < markers.length;i++){
usemarkers.push(markers[i]);
}
}
//If some checked
else {
info = [];
usemarkers=[]
}
for (var i = 0; i < checkedPlace.length; i++){
if (checkedPlace[i]=="1939"){
var addto = 14;
}
else{
var addto = 4
}
for (var k = 0; k < markers.length;k++){
if (markers[k].category >= Number(checkedPlace[i]) && Number(checkedPlace[i])+addto >= markers[k].category){
usemarkers.push(markers[k])
}
}
}
markerClusterer.setMap(null);
markerClusterer = new MarkerClusterer(map,usemarkers, {imagePath:
'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m',
maxZoom: 7,
minimumClusterSize: 3}
);
}
var search = function(){
var input = document.getElementById("newsearch").value;
alert(input);
//If none checked
if (input.length == 0){
info = JSON.parse(JSON.stringify(data));
usemarkers= []
for (var i = 0; i < markers.length;i++){
usemarkers.push(markers[i]);
}
}
//If some checked
else {
info = [];
usemarkers=[]
}
for (var k = 0; k < markers.length;k++){
if (markers[k].category == Number(input)){
usemarkers.push(markers[k])
}
}
markerClusterer.setMap(null);
markerClusterer = new MarkerClusterer(map,usemarkers, {imagePath:
'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m',
maxZoom: 7,
minimumClusterSize: 3}
);
}
var map;
var markers = [];
var people = [];
var infowindow;
var data = [["David", "Abrameto", "davabrameto@alum.mit.edu", " 2B", 2001, 37.9270095, -122.31216780000001, "6750 Snowdon Ave El Cerrito, CA"], ["Paul", "Acosta", " ", " 8", 1992, 42.321648700000004, -71.1988005, "100 Athelstane Rd Newton Center, MA"], ["Ozymandias", "Agar", "oagar@alum.mit.edu", " 3A", 2013, 0.0, 0.0, NaN], ["Kevin", "Agatstein", "kevin.agatstein@alum.mit.edu", "10", 1997, 42.3486285, -71.0902651, "390 Commonwealth Ave Apt 308 Boston, MA"], ["Sunil", "Aggarwal", "sunil.aggarwal@sloan.mit.edu", "15", 2003, 40.7590777, -73.9736148, "55 East 52nd Street New York, NY"]];
var info = JSON.parse(JSON.stringify(data));
var usemarkers=[];
var markerClusterer;
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAKNI8OZHzjpGcVpU367f7KmdfIIjQDGHs&callback=starter">
</script>
<script src="C:\Users\Neel\Desktop\markerclusterer.js"></script>
</body>
</html>