Skip to content

Instantly share code, notes, and snippets.

@andredelgado
Created November 5, 2014 17:40
Show Gist options
  • Save andredelgado/32109d83422b3a645e63 to your computer and use it in GitHub Desktop.
Save andredelgado/32109d83422b3a645e63 to your computer and use it in GitHub Desktop.
get location
var lat = 0;
var longi = 0;
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
console.log("Geolocation is not supported by this browser.");
}
}
function showPosition(position) {
lat = position.coords.latitude;
longi = position.coords.longitude;
}
getLocation();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment