UX: Wetter-Preset + robusteres Tile-Prefetch (gemeinsamer LastPos), SW by-v1091
Beide nutzen jetzt by_last_position aus localStorage: - wetter.js: speichert jede erfolgreiche GPS-Position; bei GPS-Fehler (kein Netz, Permission verweigert) wird der letzte bekannte Ort als Fallback genutzt — kein Error-Banner mehr wenn man ihn schon einmal hatte - offline-indicator.js: _prefetchTiles versucht erst GPS, fällt dann auf den gespeicherten letzten Ort zurück → Step 5 wird auch ohne aktive GPS-Permission grün, sobald Wetter (oder andere Module) einmal eine Position eingeloggt haben - TILE_MIN von 50 auf 20 gesenkt — 5x4 Tiles reichen für eine brauchbare Offline-Karte im Nahbereich
This commit is contained in:
parent
2876469e91
commit
0ba0de12b3
6 changed files with 65 additions and 24 deletions
|
|
@ -91,12 +91,31 @@ window.Page_wetter = (() => {
|
|||
`;
|
||||
}
|
||||
|
||||
const LS_LAST_POS = 'by_last_position';
|
||||
|
||||
async function _tryAutoLocate() {
|
||||
// Letzte bekannte Position als Fallback einlesen (für offline / GPS-verweigert)
|
||||
let cached = null;
|
||||
try {
|
||||
const raw = localStorage.getItem(LS_LAST_POS);
|
||||
if (raw) cached = JSON.parse(raw);
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
const pos = await API.getLocation({ timeout: 8000, maximumAge: 300_000 });
|
||||
try {
|
||||
localStorage.setItem(LS_LAST_POS, JSON.stringify({
|
||||
lat: pos.lat, lon: pos.lon, ts: Date.now(),
|
||||
}));
|
||||
} catch {}
|
||||
await _loadData(pos.lat, pos.lon);
|
||||
} catch (err) {
|
||||
_showLocationError(err?.code);
|
||||
// GPS fehlgeschlagen → letzte bekannte Position nutzen (statt Error-Banner)
|
||||
if (cached?.lat != null && cached?.lon != null) {
|
||||
await _loadData(cached.lat, cached.lon);
|
||||
} else {
|
||||
_showLocationError(err?.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue