Add files via upload
This commit is contained in:
1 parent
04c3b721a8
commit
cad6d24738
2 files changed
+50
-9
No files matched your search
+49
-8
@@ -2153,6 +2153,14 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Update Page Title dynamisch
|
||||||
|
const titles = {
|
||||||
|
'departures': 'VBB Netz Status - Abfahrten',
|
||||||
|
'journey': 'VBB Netz Status - Route',
|
||||||
|
'livemap': 'VBB Netz Status - Live-Map'
|
||||||
|
};
|
||||||
|
document.title = titles[viewName] || 'VBB Netz Status';
|
||||||
|
|
||||||
// Switch views
|
// Switch views
|
||||||
const viewLiveMap = document.getElementById('view-livemap');
|
const viewLiveMap = document.getElementById('view-livemap');
|
||||||
|
|
||||||
@@ -2206,6 +2214,9 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Initialen Title setzen (für default View 'departures')
|
||||||
|
document.title = 'VBB Netz Status - Abfahrten';
|
||||||
|
|
||||||
// Pull-to-refresh
|
// Pull-to-refresh
|
||||||
let startY = 0;
|
let startY = 0;
|
||||||
let pulling = false;
|
let pulling = false;
|
||||||
@@ -3676,6 +3687,7 @@
|
|||||||
let vehicleMarkers = [];
|
let vehicleMarkers = [];
|
||||||
let liveMapUpdateInterval = null;
|
let liveMapUpdateInterval = null;
|
||||||
let activeVehicleTypes = new Set(['all']);
|
let activeVehicleTypes = new Set(['all']);
|
||||||
|
let debounceTimer = null;
|
||||||
|
|
||||||
// Fahrzeug-Icons nach Typ
|
// Fahrzeug-Icons nach Typ
|
||||||
function getVehicleEmoji(product, lineName) {
|
function getVehicleEmoji(product, lineName) {
|
||||||
@@ -3835,11 +3847,23 @@
|
|||||||
subdomains: 'abcd'
|
subdomains: 'abcd'
|
||||||
}).addTo(liveMap);
|
}).addTo(liveMap);
|
||||||
|
|
||||||
// Fahrzeuge laden
|
// Fahrzeuge initial laden
|
||||||
loadVehicles();
|
loadVehicles();
|
||||||
|
|
||||||
// Auto-Update alle 10 Sekunden
|
// Auto-Update alle 15 Sekunden (erhöht von 10s)
|
||||||
liveMapUpdateInterval = setInterval(loadVehicles, 10000);
|
liveMapUpdateInterval = setInterval(loadVehicles, 15000);
|
||||||
|
|
||||||
|
// Event-Listener: Neu laden wenn Karte bewegt/gezoomt wird
|
||||||
|
// Mit Debouncing (1 Sekunde Verzögerung) um API zu schonen
|
||||||
|
liveMap.on('moveend', function() {
|
||||||
|
clearTimeout(debounceTimer);
|
||||||
|
debounceTimer = setTimeout(() => {
|
||||||
|
console.log('Map moved/zoomed, reloading vehicles...');
|
||||||
|
loadVehicles();
|
||||||
|
}, 1000); // 1 Sekunde warten nach Bewegung
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Live-Map initialisiert mit dynamischen Bounds');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fahrzeuge von API laden
|
// Fahrzeuge von API laden
|
||||||
@@ -3851,14 +3875,30 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Berlin Bounding Box
|
// Loading-State anzeigen
|
||||||
|
const counterEl = document.getElementById('vehicleCount');
|
||||||
|
if (counterEl) {
|
||||||
|
counterEl.innerHTML = '⏳ <span style="color: #fff;">Lade...</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dynamische Bounding Box vom aktuellen Kartenausschnitt
|
||||||
|
const mapBounds = liveMap.getBounds();
|
||||||
|
|
||||||
|
// Puffer hinzufügen (15% größer) damit Fahrzeuge nicht sofort verschwinden
|
||||||
|
const latDiff = mapBounds.getNorth() - mapBounds.getSouth();
|
||||||
|
const lngDiff = mapBounds.getEast() - mapBounds.getWest();
|
||||||
|
const latPadding = latDiff * 0.15;
|
||||||
|
const lngPadding = lngDiff * 0.15;
|
||||||
|
|
||||||
const bounds = {
|
const bounds = {
|
||||||
north: 52.70,
|
north: Math.min(52.70, mapBounds.getNorth() + latPadding), // Max: Berlin Nord
|
||||||
south: 52.35,
|
south: Math.max(52.35, mapBounds.getSouth() - latPadding), // Min: Berlin Süd
|
||||||
west: 13.08,
|
west: Math.max(13.08, mapBounds.getWest() - lngPadding), // Min: Berlin West
|
||||||
east: 13.76
|
east: Math.min(13.76, mapBounds.getEast() + lngPadding) // Max: Berlin Ost
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('Loading vehicles for bounds:', bounds);
|
||||||
|
|
||||||
const url = `${API_BASE}/radar?` +
|
const url = `${API_BASE}/radar?` +
|
||||||
`north=${bounds.north}&south=${bounds.south}&` +
|
`north=${bounds.north}&south=${bounds.south}&` +
|
||||||
`west=${bounds.west}&east=${bounds.east}&` +
|
`west=${bounds.west}&east=${bounds.east}&` +
|
||||||
@@ -3869,6 +3909,7 @@
|
|||||||
if (!response.ok) throw new Error('Radar API Error');
|
if (!response.ok) throw new Error('Radar API Error');
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
console.log('API returned', data.movements?.length || 0, 'vehicles');
|
||||||
displayVehicles(data.movements || []);
|
displayVehicles(data.movements || []);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
const CACHE_NAME = 'vbb-status-v20';
|
const CACHE_NAME = 'vbb-status-v22';
|
||||||
const urlsToCache = [
|
const urlsToCache = [
|
||||||
'/',
|
'/',
|
||||||
'/index.html',
|
'/index.html',
|
||||||
|
|||||||
Reference in new issue
Block a user