// ============================= // Karte initialisieren // ============================= const map = L.map('map').setView([52.52, 13.405], 13); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: 'ยฉ OpenStreetMap contributors' }).addTo(map); // Layer fรผr Fahrzeuge const vehiclesLayer = L.layerGroup().addTo(map); const vehicleMarkers = {}; // ============================= // Farben & Symbole // ============================= const lineColors = { 'S45': '#CD9C53', 'S46': '#CD9C53', 'S47': '#CD9C53', 'S6': '#CD9C53', 'S65': '#CD9C53', 'S66': '#CD9C53', 'S42': '#CB6418', 'S4': '#AD5937', 'S41': '#AD5937', 'U5': '#7E5330', 'U55': '#7E5330', 'S9': '#992746', 'S95': '#992746', 'S96': '#992746', 'U12': ['#7DAD4C', '#DA421E'], 'U2': '#DA421E', 'S3': '#EB7405', 'S5': '#EB7405', 'S55': '#EB7405', 'S56': '#EB7405', 'U9': '#F3791D', 'S3-wannsee': '#F0D722', 'U4': '#F0D722', 'U1': '#7DAD4C', 'U15': '#7DAD4C', 'S8': '#66AA22', 'S85': '#66AA22', 'S86': '#66AA22', 'S2': '#007734', 'S21': '#007734', 'S25': '#007734', 'S26': '#007734', 'U3': '#16683D', 'U35': '#16683D', 'S3-charlottenburg': '#009BD5', 'U7': '#009BD5', 'S10': '#0082C4', 'S19': '#0082C4', 'S3-berlin-schoenefeld': '#0066AD', 'S35': '#0066AD', 'S36': '#0066AD', 'U8': '#224F86', 'S7': '#816DA6', 'S75': '#816DA6', 'S76': '#816DA6', 'U6': '#8C6DAB', 'S1': '#DA6BA2', 'S15': '#DA6BA2', 'S16': '#DA6BA2', 'U0': '#DA6BA2', 'U10': '#808080', 'U11': '#808080', 'F10': '#528DBA', 'F11': '#528DBA', 'F12': '#528DBA', 'F21': '#528DBA', 'F23': '#528DBA', 'F24': '#528DBA' }; const symbols = { bus: '๐', tram: '๐', subway: '๐', suburban: '๐', regional: '๐', express: '๐', longDistance: '๐ ', ferry: '๐ฅ๏ธ' }; // ============================= // Aktive Filter // ============================= let activeProducts = Array.from(document.querySelectorAll('#controls input[type="checkbox"]')) .filter(c => c.checked) .map(c => c.value); // Checkbox Event document.querySelectorAll('#controls input[type="checkbox"]').forEach(cb => { cb.addEventListener('change', () => { activeProducts = Array.from(document.querySelectorAll('#controls input[type="checkbox"]')) .filter(c => c.checked) .map(c => c.value); Object.values(vehicleMarkers).forEach(marker => { const prod = marker.options.vehicleProduct || ''; if (activeProducts.includes(prod)) { if (!map.hasLayer(marker)) map.addLayer(marker); } else { if (map.hasLayer(marker)) map.removeLayer(marker); } }); }); }); // ============================= // Hilfsfunktionen // ============================= function getLineColor(lineName, product) { if(lineName === 'U12') return null; if(lineName.startsWith('S3 ')) { if(lineName.toLowerCase().includes('wannsee')) return lineColors['S3-wannsee']; if(lineName.toLowerCase().includes('charlottenburg') || lineName.toLowerCase().includes('schรถnefeld')) return lineColors['S3-berlin-schoenefeld']; return lineColors['S3']; } if(lineColors[lineName]) return lineColors[lineName]; if(product === 'suburban') return '#CD9C53'; if(product === 'subway') return '#7DAD4C'; return '#666'; } function createDivIcon(vehicle) { const product = vehicle.line?.product || ''; const lineName = vehicle.line?.name || '?'; const symbol = symbols[product] || 'โ'; if(lineName === 'U12') { const iconHtml = `