-
-
Save elbuo8/10001591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<head> | |
<link href="css/bootstrap.css" rel="stylesheet"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" id="jquery"></script> | |
</head> | |
<html> | |
<title>localchat</title> | |
<body> | |
<h1>Sorry, we don't have much stuff yet!</h1> | |
<!--- | |
<input type="button" value="Show location" onclick="javascript:showlocation();" /> <br/> | |
Latitude: <span id="latitude"></span> <br/> | |
Longitude: <span id="longitude"></span>----> | |
<br> | |
<div id="names"> | |
</div> | |
<script type="text/javascript"> | |
function fslocation(name, distance, id) { | |
this.name = name; | |
this.distance = distance; | |
this.id; | |
}; | |
var getlocationArray = function(url) { | |
var locArr = []; | |
$.getJSON(url, function (data) { | |
$.each(data.response.venues, function (i,venues) { | |
content = "<p>" + "name: " + venues.name + " distance: " + venues.location.distance + " id: " + venues.id + "</p>"; | |
$(content).appendTo("#names"); | |
var loc = new fslocation(venues.name, venues.distance, venues.id); | |
locArr.push(loc); | |
}); | |
}); | |
return locArr; | |
}; | |
//This will loop through a location array | |
var getnearestlocation = function (locArray) { | |
min=locArray[0]; | |
for(var i = 1; i < locArray.length; i++) { | |
if(locArray[i].distance > min.distance) { | |
min=locArray[i]; | |
} | |
} | |
return min; | |
} | |
var baseurl="https://api.foursquare.com/v2/venues/search?"; | |
var id="client_id=R3KEC5QXX1QAWWVFDJT32RMJF4GP0CBB3PX5D3DIKFJTR0K5"; | |
var secret="&client_secret=HUO1BXW4Z12ZELV1AGVDSCHV3EE4RVH2EGPFLEKE535VR3JO"; | |
var version="&v=20140405"; | |
var ll="&ll=40.805, -73.961" | |
//var query="&query=sushi" | |
//var radius="&radius=300" | |
var url = baseurl+id+secret+version+ll//+radius; | |
document.write(url); | |
getnearestlocation(getlocationArray(url)); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment