Skip to content

Instantly share code, notes, and snippets.

@jerryasher
Created September 2, 2017 18:30
Show Gist options
  • Save jerryasher/f6c3ec82fc505621b864c857f8f4cd3f to your computer and use it in GitHub Desktop.
Save jerryasher/f6c3ec82fc505621b864c857f8f4cd3f to your computer and use it in GitHub Desktop.
map.md
Title: Map
Date: 2017-08-31
Tags: spa
stuff
<h1>Finding Me</h1>
<button onclick="getLocation()">Where am I?</button>
<p id="location"></p>
more stuff
<script>
function getLocation()
{
// this works
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(getPosition);
} else {
// what breaks
alert("Oops! This browser does not support HTML Geolocation.");
}
}
function getPosition(position)
{
document.getElementById("location").innerHTML = "Latitude: " + position.coords.latitude + "<br>" + "Longitude: " + position.coords.longitude;
}
</script>
final stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment