Improve desktop geolocation handling
This commit is contained in:
parent
07080c79d3
commit
c3999d796d
2 changed files with 28 additions and 2 deletions
|
|
@ -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 site’s 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}
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue