Skip to content

Instantly share code, notes, and snippets.

@joemaidman
Last active September 7, 2015 12:11
Show Gist options
  • Save joemaidman/d43dbb657bec9ef7b073 to your computer and use it in GitHub Desktop.
Save joemaidman/d43dbb657bec9ef7b073 to your computer and use it in GitHub Desktop.
Javascript/HTML5 Geolocation
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment