Last active
May 13, 2016 23:23
-
-
Save ardeay/228e790a76b4e53cb0064337dffc118b 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
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