You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
785 B

// geolocation-worker.js
// Handle the geolocation updates
//~ function handlePositionUpdate(position) {
//~ // Process the position data, e.g., post it back to the main thread
//~ self.postMessage(position);
//~ }
//~ console.log("navigator",navigator);
//~ // Set up a watch for position changes
//~ const watchId = navigator.geolocation.watchPosition(
//~ handlePositionUpdate,
//~ (error) => console.error('Geolocation error:', error)
//~ );
//~ // Terminate the worker when needed
//~ self.addEventListener('terminate', () => {
//~ navigator.geolocation.clearWatch(watchId);
//~ });
self.onmessage = (event) => {
const position = event.data;
console.log('New geolocation data received in the worker:', position);
// Process the geolocation data as needed
};