Skip to content

Instantly share code, notes, and snippets.

@imanilchaudhari
Created March 8, 2021 20:53
Show Gist options
  • Save imanilchaudhari/867f1ea6b4f9970219df9e78467f09b1 to your computer and use it in GitHub Desktop.
Save imanilchaudhari/867f1ea6b4f9970219df9e78467f09b1 to your computer and use it in GitHub Desktop.
Get Browsers Geolocation
if (navigator.geolocation) {
navigator.geolocation.watchPosition (gotLocation, errLocation, {maximumAge: 30000});
}
function gotLocation (position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var accuracy = position.coords.accuracy;
var timestamp = position.timestamp;
}
function errLocation (error) {
var errCode = error.code;
var errMess = error.message;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment