If you're trying to capture a user's latitude and longitude coordinates in order to plug into an api, below is the easiest way I have found.
function userLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showData);
} else {
alert("not supported");
}
function showData(position) {
var x= position.coords.latitude;
var y = position.coords.longitude;
$("#mydiv").html("latitude: " + x + "<br/>longitude" + y);
}
}
Check out my golf game for iPhone
No comments:
Post a Comment