commit
5bddb76667
20
main.js
20
main.js
|
@ -8,8 +8,10 @@ if (!'geolocation' in navigator) {
|
||||||
speedDiv.innerHTML = 'No API'
|
speedDiv.innerHTML = 'No API'
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const WID = navigator.geolocation.watchPosition( function (loc) {
|
const WID = navigator.geolocation.watchPosition(
|
||||||
// got speed
|
|
||||||
|
// Success
|
||||||
|
function (loc) {
|
||||||
if (loc.coords.speed) {
|
if (loc.coords.speed) {
|
||||||
console.log('Got speed:',loc.coords.speed)
|
console.log('Got speed:',loc.coords.speed)
|
||||||
// convert to mph and display
|
// convert to mph and display
|
||||||
|
@ -17,5 +19,17 @@ if (!'geolocation' in navigator) {
|
||||||
} else {
|
} else {
|
||||||
speedDiv.innerHTML = '0.0'
|
speedDiv.innerHTML = '0.0'
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
|
||||||
|
// Error
|
||||||
|
function() {
|
||||||
|
console.error('Could not determine GPS position')
|
||||||
|
},
|
||||||
|
|
||||||
|
// Options
|
||||||
|
{
|
||||||
|
enableHighAccuracy: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue