Skip to content

Instantly share code, notes, and snippets.

@jerryasher
Created September 2, 2017 18:29
Show Gist options
  • Save jerryasher/cf1b47cbfadc3ac0077bc5e2b3ca0b21 to your computer and use it in GitHub Desktop.
Save jerryasher/cf1b47cbfadc3ac0077bc5e2b3ca0b21 to your computer and use it in GitHub Desktop.
mapit.md
Title: Mapit
Date: 2017-09-02
Tags: spa
stuff
<h1>Finding Me</h1>
<button onclick="getLocation3()">Where am I?</button>
<p id="location3"></p>
more stuff
<script>
function getLocation3()
{
// Check whether browser supports Geolocation API or not
if (navigator.geolocation) { // Supported
// To add PositionOptions
navigator.geolocation.getCurrentPosition(getPosition3);
} else { // Not supported
alert("Oops! This browser does not support HTML Geolocation.");
}
}
function getPosition3(position)
{
document.getElementById("location3").innerHTML =
"Latitude: " + position.coords.latitude + "<br>" +
"Longitude: " + position.coords.longitude;
}
// To add catchError(positionError) function
</script>
final stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment