Add geolocation test code
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Alessio Davoli 2023-07-18 17:40:32 +02:00
parent 7280d80e3f
commit 814e1ee444

View file

@ -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);