Improve desktop geolocation handling

This commit is contained in:
Edward Betts 2026-08-15 12:53:41 +01:00
parent 07080c79d3
commit c3999d796d
2 changed files with 28 additions and 2 deletions

View file

@ -605,8 +605,17 @@ byId('locate-button').addEventListener('click', () => {
const apiParams = new URLSearchParams({...coordinates, label: 'Your location'});
loadUrl(`${API_URLS.stops}?${apiParams}`);
},
() => { setLoading(false); showError('Location access was denied or unavailable.'); },
{enableHighAccuracy: true, timeout: 10000}
error => {
setLoading(false);
const messages = {
1: 'Location permission was denied. Check this sites location permission in your browser.',
2: 'Your browser could not determine your location. Check that device or operating-system location services are enabled.',
3: 'Determining your location timed out. Try again, or enter latitude and longitude manually.',
};
showError(messages[error.code] || `Could not determine your location${error.message ? `: ${error.message}` : '.'}`);
},
// Desktop browsers usually rely on network location rather than GPS.
{enableHighAccuracy: false, timeout: 20000, maximumAge: 300000}
);
});