Added GPS coordinates

Signed-off-by: Keith Irwin <mail@keithirwin.us>
master
Keith Irwin 2016-12-13 18:52:23 -05:00
parent 1f2a8ec59a
commit a2859e545e
2 changed files with 17 additions and 3 deletions

View File

@ -41,7 +41,7 @@
<body>
<header>
<div class='error' id='no-gps'>No GPS data available. <br><a href="javascript:tryGPS()">retry</a></div>
<div class='error' id='no-gps'>No GPS data available. </div>
<div class='coord' id='lat'></div>
<div class='coord' id='lon'></div>

View File

@ -1,7 +1,21 @@
window.addEventListener("deviceorientation", setRose, true);
function tryGPS() {
if (!navigator.geolocation){ $('#no-gps').show(); }
else {
navigator.geolocation.watchPosition(
// success
function(e) {
$('#lat').text(e.coords.latitude);
$('#lon').text(e.coords.longitude);
},
// error
function() {
$('.coord').hide();
$('#no-gps').show();
},
// options
{ enableHighAccuracy:true }
);
}
function setRose(e) {