Add geolocalization
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Alessio Davoli 2023-07-18 17:31:01 +02:00
parent e451902f38
commit bfba81c09b
2 changed files with 7 additions and 12 deletions

View file

@ -4,12 +4,9 @@ let longitude;
onmessage = () => { onmessage = () => {
const watchID = navigator.geolocation.watchPosition((position) => {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
});
console.log({latitude, longitude});
}; };
export { }; export { };

View file

@ -11,13 +11,11 @@
/* geolocation is not available */ /* geolocation is not available */
return; return;
} }
const SyncWorker = await import('$lib/gps.worker.ts'); const watchID = navigator.geolocation.watchPosition((position) => {
syncWorker = new SyncWorker.default(); latitude = position.coords.latitude;
syncWorker.postMessage([]); longitude = position.coords.longitude;
syncWorker.onmessage = (data) => { console.log({latitude, longitude});
console.log(data); });
}
}; };
onMount(loadWorker); onMount(loadWorker);