Add geolocation test code
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
7280d80e3f
commit
814e1ee444
1 changed files with 26 additions and 5 deletions
|
@ -11,11 +11,32 @@
|
|||
/* geolocation is not available */
|
||||
return;
|
||||
}
|
||||
const watchID = navigator.geolocation.watchPosition((position) => {
|
||||
latitude = position.coords.latitude;
|
||||
longitude = position.coords.longitude;
|
||||
console.log({latitude, longitude});
|
||||
});
|
||||
// const watchID = navigator.geolocation.watchPosition((position) => {
|
||||
// latitude = position.coords.latitude;
|
||||
// longitude = position.coords.longitude;
|
||||
// console.log({latitude, longitude});
|
||||
// });
|
||||
|
||||
const options = {
|
||||
enableHighAccuracy: true,
|
||||
timeout: 5000,
|
||||
maximumAge: 0,
|
||||
};
|
||||
|
||||
function success(pos) {
|
||||
const crd = pos.coords;
|
||||
|
||||
console.log("Your current position is:");
|
||||
console.log(`Latitude : ${crd.latitude}`);
|
||||
console.log(`Longitude: ${crd.longitude}`);
|
||||
console.log(`More or less ${crd.accuracy} meters.`);
|
||||
}
|
||||
|
||||
function error(err) {
|
||||
console.warn(`ERROR(${err.code}): ${err.message}`);
|
||||
}
|
||||
|
||||
navigator.geolocation.getCurrentPosition(success, error, options);
|
||||
};
|
||||
|
||||
onMount(loadWorker);
|
||||
|
|
Loading…
Reference in a new issue