Skip to content

Commit 6f643de

Browse files
Merge pull request #1 from giancarloerra:fix/geolocation-timeout
fix: add timeout to geolocation request
2 parents 2e14aa2 + 8ed7778 commit 6f643de

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

public/settings.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,23 @@ <h2><span class="icon">✨</span> Features</h2>
274274

275275
function useGeolocation() {
276276
if (!navigator.geolocation) { toast('Geolocation not supported by this browser', true); return; }
277+
toast('Locating…');
277278
navigator.geolocation.getCurrentPosition(
278279
pos => {
279280
document.getElementById('inp-lat').value = pos.coords.latitude.toFixed(4);
280281
document.getElementById('inp-lon').value = pos.coords.longitude.toFixed(4);
281282
// altitude not reliably available from browser — leave as-is
282283
toast('Coordinates filled — click Save Location to confirm');
283284
},
284-
() => toast('GPS permission denied or unavailable', true)
285+
err => {
286+
const msgs = {
287+
1: 'GPS permission denied',
288+
2: 'Position unavailable — try again or enter coordinates manually',
289+
3: 'Location request timed out — try again',
290+
};
291+
toast(msgs[err.code] || 'Geolocation failed', true);
292+
},
293+
{ enableHighAccuracy: false, timeout: 15000, maximumAge: 300000 }
285294
);
286295
}
287296

0 commit comments

Comments
 (0)