parent
1f2a8ec59a
commit
a2859e545e
|
@ -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>
|
||||
|
|
18
script.js
18
script.js
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue