Fix: Routen-Aufzeichnung offline — Dim-Screen + WakeLock + GPS funktionieren

_startRecInOvl() crashte bei null _recMap auf L.polyline().addTo(_recMap) →
WakeLock, watchPosition, _resetRecInactTimer() wurden nie erreicht → Dim-Screen
wurde nie aktiviert, GPS-Track lief nicht.

- L.polyline nur erstellen wenn _recMap && window.L vorhanden
- watchPosition-Callback: _recPolyline?.addLatLng, _recLocMarker?.setLatLng,
  _recMap?.setView alle mit Optional Chaining gesichert
- SW by-v996, APP_VER 996
This commit is contained in:
rene 2026-05-15 18:19:55 +02:00
parent c59326af17
commit 1d67d6307e
4 changed files with 9 additions and 7 deletions

View file

@ -821,7 +821,9 @@ window.Page_routes = (() => {
btn.addEventListener('pointercancel', cancelHold);
document.getElementById('rk-rec-stats-bar').style.display = '';
_recPolyline = L.polyline([], { color: '#ef4444', weight: 5, opacity: 0.9 }).addTo(_recMap);
if (_recMap && window.L) {
_recPolyline = L.polyline([], { color: '#ef4444', weight: 5, opacity: 0.9 }).addTo(_recMap);
}
await _recAcquireWakeLock();
document.addEventListener('visibilitychange', _recOnVisibility);
@ -836,9 +838,9 @@ window.Page_routes = (() => {
_recDistKm += d;
}
_recTrack.push({ lat, lon, ...(alt !== null ? { alt: Math.round(alt) } : {}) });
_recPolyline.addLatLng([lat, lon]);
_recLocMarker.setLatLng([lat, lon]);
if (_recTrack.length === 1) _recMap.setView([lat, lon], 16);
_recPolyline?.addLatLng([lat, lon]);
_recLocMarker?.setLatLng([lat, lon]);
if (_recTrack.length === 1) _recMap?.setView([lat, lon], 16);
_updateRecStats();
}, () => {}, { enableHighAccuracy: true, maximumAge: 2000 });