Skip to content

Instantly share code, notes, and snippets.

@joyrexus
Created January 27, 2014 23:25
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 joyrexus/8659524 to your computer and use it in GitHub Desktop.
Save joyrexus/8659524 to your computer and use it in GitHub Desktop.
Geolocation demo

Shows your current location coordinates using the Geolocation API.

See this tutorial for more details.

<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,
minimum-scale=1.0">
<style>
html {
margin: 80px;
font-family: "Helvetica Neue";
font-weight: 100;
font-size: 100px;
color: #999;
}
</style>
<div id="lat">Latitude</div>
<div id="lon">Longitude</div>
<script>
navigator.geolocation.watchPosition(render);
function render(pos){
lat.innerText = pos.coords.latitude.toFixed(7);
lon.innerText = pos.coords.longitude.toFixed(7);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment