const trackBtn = document.
getElementById('trackBtn');
const statusDiv = [Link]('status');
[Link]('click', () => {
if ([Link]) {
// Request permission and get location
[Link](
(position) => {
const { latitude, longitude } = [Link];
[Link] = `Location: ${latitude}, ${longitude}`;
// Send to backend (replace with actual user ID from auth)
fetch('[Link] {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: [Link]({ userId: 'exampleUser', latitude, longitude })
}).then(() => [Link]('Location saved'));
},
(error) => {
[Link] = `Error: ${[Link]}`;
},
{ enableHighAccuracy: true, timeout: 10000 }
);
} else {
[Link] = 'Geolocation not supported.';
}
});
// Optional: Fetch and display past locations
function loadLocations(userId) {
fetch(`[Link]
.then(res => [Link]())
.then(data => {
// Render on a map or list (e.g., using [Link] for free maps)
[Link](data);
});
}