Created
April 20, 2012 02:29
-
-
Save billy-the-kid/2425394 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
////////// | |
/////////user location | |
function getUserLocation() { | |
console.log("setting location vals1"); | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(itsWorking, notWorking); | |
} | |
else { | |
alert("Dang! Your browser doesn't support finding your location, use the zipcode method below."); | |
} | |
}; | |
function itsWorking(position) { | |
var lat = position.coords.latitude; | |
var longi = position.coords.longitude; | |
var finalLat = Math.round(lat*1000000)/1000000 | |
var finalLong = Math.round(longi*1000000)/1000000 | |
$("#longi").val(finalLong); | |
$("#lati").val(finalLat); | |
console.log("setting location vals"); | |
}; | |
function notWorking(error) { | |
var locationElement = document.getElementById("locationData"); | |
switch(error.code) { | |
case error.PERMISSION_DENIED: alert("Permission was denied"); | |
break; | |
case error.POSITION_UNAVAILABLE: alert("Location data not available"); | |
break; | |
case error.TIMEOUT: alert("Location request timeout"); | |
break; | |
case error.UNKNOWN_ERROR: alert("An unspecified error occurred"); | |
break; | |
default: alert("Who knows what happened..."); | |
break; | |
}; | |
}; | |
////////// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment