From 2c16642992c20ea3deb5c9adfe256f1c2bfae141 Mon Sep 17 00:00:00 2001 From: Joachim Hummel Date: Fri, 14 Nov 2025 15:47:26 +0000 Subject: [PATCH] Add detailed coordinate debugging and validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Log latitude/longitude values and types before parsing - Add null checks for marker_label and display_time - Improve history polyline filtering for invalid coords - Show "Keine aktuelle Position" when no current location 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- index_owntrack.html | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/index_owntrack.html b/index_owntrack.html index a30978a..80042c1 100644 --- a/index_owntrack.html +++ b/index_owntrack.html @@ -117,10 +117,21 @@ if (data.current) { const loc = data.current; - console.log('Current location:', loc); + console.log('Current location object:', loc); + console.log('latitude field:', loc.latitude, 'type:', typeof loc.latitude); + console.log('longitude field:', loc.longitude, 'type:', typeof loc.longitude); + + const lat = parseFloat(loc.latitude); + const lon = parseFloat(loc.longitude); + + console.log('Parsed lat:', lat, 'lon:', lon); + + if (isNaN(lat) || isNaN(lon)) { + throw new Error(`Invalid coordinates: lat=${loc.latitude} (${typeof loc.latitude}), lon=${loc.longitude} (${typeof loc.longitude})`); + } // Popup-Inhalt aufbauen - let popupContent = `${loc.marker_label}
${loc.display_time}`; + let popupContent = `${loc.marker_label || 'Unknown'}
${loc.display_time || ''}`; // Batterie hinzufügen, falls vorhanden if (loc.battery !== undefined && loc.battery !== null) { @@ -133,13 +144,6 @@ popupContent += `
🚗 Speed: ${speedKmh} km/h`; } - const lat = parseFloat(loc.latitude); - const lon = parseFloat(loc.longitude); - - if (isNaN(lat) || isNaN(lon)) { - throw new Error(`Invalid coordinates: lat=${loc.latitude}, lon=${loc.longitude}`); - } - const marker = L.marker([lat, lon]) .addTo(map) .bindPopup(popupContent) @@ -151,12 +155,25 @@ // Historie als Linie if (data.history && data.history.length > 1) { - const coords = data.history.map(h => [parseFloat(h.latitude), parseFloat(h.longitude)]); - const polyline = L.polyline(coords, {color: 'blue', weight: 3}).addTo(map); - polylines.push(polyline); + const coords = data.history + .map(h => { + const hlat = parseFloat(h.latitude); + const hlon = parseFloat(h.longitude); + if (!isNaN(hlat) && !isNaN(hlon)) { + return [hlat, hlon]; + } + return null; + }) + .filter(c => c !== null); + + if (coords.length > 1) { + const polyline = L.polyline(coords, {color: 'blue', weight: 3}).addTo(map); + polylines.push(polyline); + } } } else { console.log('No current location in response'); + statusDiv.innerHTML += '
Keine aktuelle Position'; } } catch (error) { console.error('Load error:', error);