Fix: Marker verschwanden offline beim Kartenbewegen — SW-503-JSON als Fehler werten

Der SW beantwortet nicht-cachebare API-GETs offline mit 503 + JSON-Body,
r.json() wirft dann NICHT -> Erfolgs-Pfad ersetzte Marker durch {detail:...}.
_fetchPois prueft jetzt r.ok + Array.isArray, dadurch greift der
IndexedDB-Fallback (MapOffline.pois) in Phase 1 und Phase 2 behaelt den Bestand.
Bump v1224
This commit is contained in:
rene 2026-06-06 11:35:03 +02:00
parent 6af08ab543
commit e6d6a3e697
6 changed files with 28 additions and 18 deletions

View file

@ -1469,12 +1469,22 @@ window.Page_map = (() => {
}
}
// POIs holen — WICHTIG: r.ok prüfen! Der SW antwortet offline auf nicht-cachebare
// API-GETs mit 503 + JSON-Body ({detail:…}) → r.json() wirft NICHT, der Erfolgs-Pfad
// liefe mit einem Objekt statt Array weiter und ersetzte die Marker durch nichts.
const _fetchPois = async (params) => {
const r = await fetch(`/api/osm/pois?${params}`);
if (!r.ok) throw new Error(`pois ${r.status}`);
const pois = await r.json();
return Array.isArray(pois) ? pois : [];
};
// Phase 1: sofort DB-Daten zeigen (fast=true)
_setOsmStatus('Lade…');
const fastTasks = activeLayers.map(async ([layerKey, osmType]) => {
const params = new URLSearchParams({ type: osmType, fast: 'true', ...bbox });
try {
const pois = await fetch(`/api/osm/pois?${params}`).then(r => r.json());
const pois = await _fetchPois(params);
_replaceOsmMarkers(layerKey, pois);
return pois.length;
} catch {
@ -1499,7 +1509,7 @@ window.Page_map = (() => {
const freshTasks = activeLayers.map(async ([layerKey, osmType]) => {
const params = new URLSearchParams({ type: osmType, ...bbox });
try {
const pois = await fetch(`/api/osm/pois?${params}`).then(r => r.json());
const pois = await _fetchPois(params);
const osmCount = _osmCountOf(layerKey);
if (pois.length !== osmCount) _replaceOsmMarkers(layerKey, pois);
_done++;