Created
March 20, 2018 22:15
-
-
Save ToeJamson/ad83831220018977cec1a329bbaf101e to your computer and use it in GitHub Desktop.
location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
window.lat = 37.7850; | |
window.lng = -122.4383; | |
function getLocation() { | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(updatePosition); | |
} | |
return null; | |
}; | |
function updatePosition(position) { | |
if (position) { | |
window.lat = position.coords.latitude; | |
window.lng = position.coords.longitude; | |
} | |
} | |
setInterval(function(){updatePosition(getLocation());}, 10000); | |
function currentLocation() { | |
return {lat:window.lat, lng:window.lng}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment