-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
229 lines (196 loc) · 6.81 KB
/
index.html
File metadata and controls
229 lines (196 loc) · 6.81 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>inBetween</title>
<meta name="description" content="inBetween" />
<meta name="keywords" value="inBetween, webapp, HTML5, jquery, geolocation, javascript, HackPrinceton" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"> </script>
<script src="http://maps.google.com/maps/api/js?sensor=false"> </script>
<script>
$(document).ready(function() {
});
function getLat(address, callback) {
if (address) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
var result = 0;
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var lati = results[0].geometry.location.lat();
result = lati;
}
}
callback(result);
});
}
else {
callback(0);
}
}
function getLon(address,callback) {
if (address) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
var result = 0;
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var longi = results[0].geometry.location.lng();
result = longi;
}
}
callback(result);
});
}
else {
// error('Please enter an address');
callback(0);
}
}
function findMe() {
// alert('You are in Princeton, NJ. \nLatitude: 40.3487° N, Longitude: 74.6593° W');
getLocation();
}
function clearForm() {
$("#names").empty();
}
function formSubmit() {
$("#names").empty();
var yours = '';
var other = '';
var interest = '';
yours = document.getElementById("yourPlace").value;
other = document.getElementById("otherPlace").value;
interest = document.getElementById("interestType").value;
findLatLong(yours, other, interest);
}
function findLatLong(yours, other, interest) {
var latitude = 0;
var longitude = 0;
var yourLoc = yours;
var otherLoc = other;
var poi = interest;
var latitude = 0;
var longitude = 0;
getLat(yourLoc, function(yourLat) {
getLat(otherLoc, function(otherLat) {
getLon(yourLoc, function(yourLon) {
getLon(otherLoc, function(otherLon) {
latitude = (yourLat + otherLat)/2;
longitude = (yourLon + otherLon)/2;
printLocs(latitude, longitude, interest);
});
});
});
});
}
function printLocs(lati, longi, query){
if (lati.toString() == 'NaN' || lati.toString() == 'null' || lati === 0)
lati = 40.5592;
if (longi.toString() == 'NaN' || longi.toString() == 'null' || longi === 0)
longi = -74.3164;
var url = 'https://api.foursquare.com/v2/venues/search?ll='+lati+','+longi+'&query='+query+'&client_id=2POUFAUU4ZBJ2MTDOY3S2YHR2NIT52FYW0LUTPHBMNTJFJNQ&client_secret=YFDZI1YWV3ZI5S5SPM2DZJEQIEBPIDJ5XFZBWTIKIQZVQNYM&v=20120101';
$.getJSON(url,
function(data) {
if(data.response.venues.length < 1)
alert('No nearby venues at the exact midpoint between you and your friend. Please try another pair of locations.');
$.each(data.response.venues, function(i,venues){
content = '<center>';
content += '<p> <br />';
if(venues.name != null) {
content += ' ' + venues.name + '<br />';
}
if(venues.location.address != null) {
content += ' ' + venues.location.address + '<br />';
}
if(venues.location.crossStreet != null) {
content += ' ' + venues.location.crossStreet + '<br />';
}
if(venues.location.city != null) {
content += ' ' + venues.location.city + ', ';
}
if(venues.location.state != null) {
content += ' ' + venues.location.state + '';
}
if(venues.location.postalCode != null) {
content += ' ' + venues.location.postalCode + '';
}
if(venues.location.distance != null) {
content += '<br /> Distance: ' + venues.location.distance + '<br />';
}
if(venues.contact.phone != null) {
content += ' ' + venues.location.phone + '<br />';
}
content += '<a href=\"https://foursquare.com/explore?near=';
content += venues.location.city + '%2C%20' + venues.location.state;
content += '&q=' + venues.name + '\">';
content += 'Find on Foursquare!</a><br />';
content += '</p> </center>';
$(content).appendTo("#names");
});
});
}
</script>
<script>
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else {
alert("Sorry, geolocation is not supported by this browser.");
}
}
function showPosition(position)
{
var whereAmI = "Latitude: " + position.coords.latitude;
whereAmI += ", Longitude: " + position.coords.longitude;
alert(whereAmI);
}
</script>
</head>
<body bgcolor="#D8D8D8">
<div id="logo">
<center>
<h1>inBetween</h1>
</center>
</div>
<div id="head">
<center>
Tell us where you are, and where your friend is. <br />
We'll help you find cool places <strong><em>inBetween</em></strong> you! <br />
</br>
</center>
</div>
<div id="top">
<center>
<form id="your_loc" method="post" action="javascript:formSubmit()">
<label for="yourPlace">Where are you now? </label>
<input type="text" id="yourPlace" name="yourPlace" size="25" maxLength="160"></input>
<br />
<label for="otherPlace">Where's your friend? </label>
<input type="text" id="otherPlace" name="otherPlace" size="25" maxLength="160"></input>
<br />
<label for="interestType">Place of interest? </label>
<input type="text" id="interestType" name="interestType" size="25" maxLength="160"></input>
<br /> <br />
<input class="button" type="button" id="button" name="button" value="Find me!" onClick="findMe()">
<br />
<input class="button" type="reset" id="reset" name="reset" value="Clear" onClick="clearForm()">
<br />
<input class="button" type="submit" id="submit" name="submit" value="Let's go!" />
<br />
</form>
</center>
</div>
<div id="head">
<center>
<br /> Now check out the awesome places nearby! <br />
</center>
</div>
<div id="map_canvas"></div>
<div id="names"></div>
</body>
</html>