Skip to content

Instantly share code, notes, and snippets.

@jerryasher
Created September 2, 2017 18:29
Show Gist options
  • Save jerryasher/b5864ec282fffc6b4f03e303d86b8820 to your computer and use it in GitHub Desktop.
Save jerryasher/b5864ec282fffc6b4f03e303d86b8820 to your computer and use it in GitHub Desktop.
mapbetter.md
Title: MapBetter
Date: 2017-09-01
Tags: spa
stuff
<h1>Finding Me</h1>
<button onclick="getLocation2()">Where am I?</button>
<p id="location2"></p>
more stuff
<script>
function getLocation2()
{
// but this does not work
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(getPosition2);
} else {
// what breaks
alert("Oops! This browser does not support HTML Geolocation.");
}
}
function getPosition2(position)
{
document.getElementById("location2").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