Skip to content

Instantly share code, notes, and snippets.

@ardeay
Last active May 13, 2016 23:23
Show Gist options
  • Save ardeay/228e790a76b4e53cb0064337dffc118b to your computer and use it in GitHub Desktop.
Save ardeay/228e790a76b4e53cb0064337dffc118b to your computer and use it in GitHub Desktop.
function geoFindMe() {
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error, geoOptions);
} else {
alert("Geolocation services are not supported by your web browser.");
}
}
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var altitude = position.coords.altitude;
var accuracy = position.coords.accuracy;
alert("lat: " + latitude + " long: " + longitude); // for testing purposes, delete this line before sending to production
// write in your logic here
}
function error(error) {
alert("Unable to retrieve your location due to " + error.code + ": " + error.message);
}
var geoOptions = {
enableHighAccuracy: true,
maximumAge: 30000,
timeout: 27000
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment