Skip to content

Instantly share code, notes, and snippets.

@blanchma
Created November 15, 2011 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blanchma/1366977 to your computer and use it in GitHub Desktop.
Save blanchma/1366977 to your computer and use it in GitHub Desktop.
Get latitude and longitude from browser
// if the browser supports the w3c geo api
if(navigator.geolocation){
// get the current position
navigator.geolocation.getCurrentPosition(
// if this was successful, get the latitude and longitude
function(position){
var lat = position.coords.latitude;
var lon = position.coords.longitude;
},
// if there was an error
function(error){
alert('ouch');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment