Skip to content

Instantly share code, notes, and snippets.

@micahwalter
Created April 23, 2014 00:28
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 micahwalter/11199023 to your computer and use it in GitHub Desktop.
Save micahwalter/11199023 to your computer and use it in GitHub Desktop.
function success(position) {
var s = document.querySelector('#status');
s.innerHTML = "found you at " + position.coords.latitude + " " + position.coords.longitude;
}
function error(msg) {
var s = document.querySelector('#status');
s.innerHTML = typeof msg == 'string' ? msg : "failed";
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment