-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathguiming.htm
More file actions
executable file
·329 lines (272 loc) · 9.98 KB
/
guiming.htm
File metadata and controls
executable file
·329 lines (272 loc) · 9.98 KB
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
<!DOCTYPE HTML>
<!--
Strongly Typed 1.1 by HTML5 UP
html5up.net | @n33co
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Welcome to Zexuan's Website'</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Zexuan Wang, Canada, Table tennis, software, resume, Aaron Wang">
<meta name="description" content="Personal website of Zexuan Wang, about his academic, table tennis and social life">
<meta name="author" content="Zexuan Wang">
<meta charset="UTF-8">
<meta name="viewport" content="width=900" />
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600|Arvo:700" rel="stylesheet" type="text/css" />
<!-- noscript -->
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-desktop.css" />
<link rel="stylesheet" href="css/style-gallery.css" />
<!-- /noscript -->
<!--[if lte IE 8]><script src="js/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.dropotron.min.js"></script>
<script src="js/config.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/skel-panels.min.js"></script>
<script src="js/gallery.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
<!-- used for mobile split-panel layout -->
<script type='text/javascript'>
var map;
var geocoder;
var latCoord=43.6584;
var lngCoord=-79.39449;//logs the current map location
var userLatCoord = 43.6584;
var userLngCoord= -79.39449;//logs the user location
var userLocation;
var userLocationMarker;
var infowindow;
var nearbySearchTypes;
var nearbySearchRadius;
var nearbySearchRankby;
var nearbyPlacesList;
function initialize() {
nearbySearchTypes = ['bank'];
nearbySearchRasius = 5000;
nearbySearchRankby=google.maps.places.RankBy.PROMINENCE;
nearbyPlacesList = new Array();
var mapOptions = {zoom: 6};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
infowindow = new google.maps.InfoWindow({maxWidth: 100, maxHeight:50});
geocoder = new google.maps.Geocoder();
// Try HTML5 geolocation
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
latCoord = position.coords.latitude;
lngCoord = position.coords.longitude;
setUserLocation();
var pos = new google.maps.LatLng(latCoord, lngCoord);
infowindow = new google.maps.InfoWindow({
map: map,
position: pos,
content: 'Current location is: ('+latCoord+','+lngCoord+')'
});
map.setCenter(pos);
}, handleNoGeolocation);
} else {
// Browser doesn't support Geolocation
handleNoGeolocation(-100);
}
userLocationMarker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(latCoord, lngCoord)
});
}
google.maps.event.addDomListener(window, 'load', initialize);
function handleNoGeolocation(errorFlag) {
if(errorFlag==-100){
var content = 'Error: The Geolocation service failed.';
}
else{
var content = 'Error: '+errorFlag.message;
}
var options = {
map: map,
position: new google.maps.LatLng(latCoord, lngCoord),
content: content
};
//var infowindow = new google.maps.InfoWindow(options);
map.setCenter(options.position);
}
function geoCodeAddress(){
var address = document.getElementById('userAddrField').value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status==google.maps.GeocoderStatus.OK){
if(results.length>1){
alert("more than one location is found");
}
latCoord = results[0].geometry.location.lat();
lngCoord = results[0].geometry.location.lng();
map.setCenter(results[0].geometry.location);
map.setZoom(12);
}
else{
alert('Geocode was not successful because: ' + status);
}
});
}
function setUserLocation(){
userLatCoord = latCoord;
userLngCoord = lngCoord;
var latlng = new google.maps.LatLng(userLatCoord,userLngCoord);
geocoder.geocode({'latLng': latlng}, function(results, status){
if (status == google.maps.GeocoderStatus.OK) {
userLocation = results[0]
createMarker(userLocation);
alert("user location is "+ userLocation.formatted_address);
map.setZoom(12);
}
});
}
function markPlacesNearby(lat, lng, types, radius, rankby){
//marks all query places near coordinates in certain radius
var coord = new google.maps.LatLng(lat, lng);
var request = {
location: coord,
radius: 500,
types: types,
rankBy:rankby
};
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, processPlaces);
}
function processPlaces(results, status){
if(status==google.maps.places.PlacesServiceStatus.OK){
var resultCount = results.length>20 ? 20:results.length;
nearbyPlacesList = results.slice(0,resultCount);
var bounds = new google.maps.LatLngBounds ();
for(var i = 0; i < resultCount; i++){
var marker = createPlaceMarker(results[i]);
bounds.extend (results[i].geometry.location);
}
// Fit these bounds to the map
map.fitBounds (bounds);
//map.setZoom(15);
}
}
function createPlaceMarker(place) {
var placeLoc = place.geometry.location;
if (place.icon) {
var image = new google.maps.MarkerImage(
place.icon, new google.maps.Size(71, 71),
new google.maps.Point(0, 0), new google.maps.Point(17, 34),
new google.maps.Size(25, 25));
} else var image = null;
var marker = new google.maps.Marker({
map: map,
icon: image,
position: place.geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
map.setCenter(placeLoc);
//infowindow.setContent(place.name);
//infowindow.open(map, this);
});
return marker;
}
function isPlaceOpenDuring(startTime,endTime, dayOfWeek, place){
//return true if the place is open at the time specified
//false if anything else. assumes opening_hours always exists
//day of week starts from Sunday (0), to 6.
//input times are in 24hr format (0000-2359)
if(dayOfWeek > 6 || dayOfWeek<0){
return false;
}
var openHour = place.opening_hours.periods[dayOfWeek].open;
var closeHour = place.opening_hours.periods[dayOfWeek].close;
if(openHour > startTime || startTime > closeHour ||
closeHour < endTime || endTime<openHour){
return false;
}
else{
return true;
}
}
$(function() {
$("#setCoordBtn").click(function(){
latVal=$("#latValField").val();
lngVal =$("#lngValField").val();
if(latVal=="")
alert("invalid latitude. value is not set.");
else{
latCoord=latVal;
userLatCoord = latVal;
}
if(lngVal=="")
alert("invalid longitude. value is not set.");
else{
lngCoord=lngVal;
userLngCoord = lngVal;
}
});
$("#reloadMapBtn").click(function(){
alert("longitude="+lngCoord+ "\n" +"latitude="+latCoord);
var options = { map: map, position: new google.maps.LatLng(latCoord,lngCoord)};
map.setCenter(options.position);
});
$("#geoCodeBtn").click(function(){
geoCodeAddress();
});
$("#setUserLocationBtn").click(function(){
setUserLocation();
});
$("#nearbyBtn").click(function(){
markPlacesNearby(userLatCoord,userLngCoord, nearbySearchTypes, nearbySearchRadius, nearbySearchRankby);
});
});
</script>
</head>
<body class="homepage">
<!-- Footer Wrapper -->
<div id="footer-wrapper">
<!-- Container -->
<div id="footer" class="container">
<div class="row">
<div class="6u">
<section>
<div class="row half">
<div class="6u">
<input id="latValField" name="latVal" placeholder="latitude" type="text" class="text" />
</div>
<div class="6u">
<input id="lngValField" name="lngVal" placeholder="longitude" type="text" class="text" />
</div>
<div class="6u">
<input id="userAddrField" name="address" placeholder="enter an address" type="text" class="text" />
</div>
</div>
<div class="row half">
<div class="12u">
<a name="setCoord" id="setCoordBtn" class="button button-icon fa fa-envelope">Set coordinate values</a>
</div>
<div class="12u">
<a name="reloadMap" id="reloadMapBtn" class="button button-icon fa fa-envelope">go to coordinates</a>
</div>
<div class="12u">
<a name="geoCode" id="geoCodeBtn" class="button button-icon fa fa-envelope">geoCode map</a>
</div>
<div class="12u">
<a name="setUserLocation" id="setUserLocationBtn" class="button button-icon fa fa-envelope">set Current Location as user's location</a>
</div>
</div>
<div class="row half">
<!--*****************************************-->
<div class="12u">
<a name="nearby" id="nearbyBtn" class="button button-icon fa fa-envelope">places nearby</a>
</div>
</div>
</section>
</div>
</div>
</div>
<div id="map-canvas" style="width: 600px; height: 400px; background-color: grey"></div>
<!-- END OF CONTAINER-->
</div>
</div>
</div>
</body>
</html>