From 40aecaafc020bcdc245e52f441bdee294b4270f6 Mon Sep 17 00:00:00 2001 From: Joachim Hummel Date: Fri, 14 Nov 2025 15:45:55 +0000 Subject: [PATCH] Add extensive debugging to loadLocations function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add console.log statements at each step - Show error message in status widget - Add coordinate validation - Remove incorrect success/failure logic 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- index_owntrack.html | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/index_owntrack.html b/index_owntrack.html index 99c005f..a30978a 100644 --- a/index_owntrack.html +++ b/index_owntrack.html @@ -92,13 +92,16 @@ async function loadLocations() { try { + console.log('Fetching locations from:', API_URL); const response = await fetch(API_URL); + console.log('Response status:', response.status); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); + console.log('Data received:', data); // Alte Marker und Linien entfernen markers.forEach(marker => map.removeLayer(marker)); @@ -106,12 +109,15 @@ markers = []; polylines = []; - document.getElementById('status').innerHTML = + // Status aktualisieren + const statusDiv = document.getElementById('status'); + statusDiv.innerHTML = `Punkte: ${data.total_points || 0}
` + - `Status: ${data.success ? '✅ Verbunden' : '❌ Fehler'}`; + `Status: ✅ Verbunden`; if (data.current) { const loc = data.current; + console.log('Current location:', loc); // Popup-Inhalt aufbauen let popupContent = `${loc.marker_label}
${loc.display_time}`; @@ -130,6 +136,10 @@ 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) @@ -145,10 +155,14 @@ const polyline = L.polyline(coords, {color: 'blue', weight: 3}).addTo(map); polylines.push(polyline); } + } else { + console.log('No current location in response'); } } catch (error) { - document.getElementById('status').innerHTML = '❌ Verbindungsfehler'; console.error('Load error:', error); + console.error('Error stack:', error.stack); + document.getElementById('status').innerHTML = + `❌ Verbindungsfehler
${error.message}`; } }