Update app.js
This commit is contained in:
1 parent
6e5d57805e
commit
b4bff670d0
1 file changed
+9
-11
@@ -8,7 +8,6 @@ L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|||||||
const vehiclesLayer = L.layerGroup().addTo(map);
|
const vehiclesLayer = L.layerGroup().addTo(map);
|
||||||
const vehicleMarkers = {};
|
const vehicleMarkers = {};
|
||||||
|
|
||||||
// BVG / DB S-Bahn Farben mit Hex + Namen
|
|
||||||
const lineColors = {
|
const lineColors = {
|
||||||
'S45': '#CD9C53', 'S46': '#CD9C53', 'S47': '#CD9C53', 'S6': '#CD9C53', 'S65': '#CD9C53', 'S66': '#CD9C53',
|
'S45': '#CD9C53', 'S46': '#CD9C53', 'S47': '#CD9C53', 'S6': '#CD9C53', 'S65': '#CD9C53', 'S66': '#CD9C53',
|
||||||
'S42': '#CB6418',
|
'S42': '#CB6418',
|
||||||
@@ -34,7 +33,6 @@ const lineColors = {
|
|||||||
'U10': '#808080', 'U11': '#808080'
|
'U10': '#808080', 'U11': '#808080'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Produkt-Symbole
|
|
||||||
const symbols = {
|
const symbols = {
|
||||||
bus: '🚌',
|
bus: '🚌',
|
||||||
tram: '🚎',
|
tram: '🚎',
|
||||||
@@ -45,11 +43,8 @@ const symbols = {
|
|||||||
longDistance: '🚅'
|
longDistance: '🚅'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hilfsfunktion, um Farbe für Linie zu bestimmen
|
|
||||||
function getLineColor(lineName, product) {
|
function getLineColor(lineName, product) {
|
||||||
if(lineName === 'U12') {
|
if(lineName === 'U12') return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lineName.startsWith('S3 ')) {
|
if(lineName.startsWith('S3 ')) {
|
||||||
if(lineName.toLowerCase().includes('wannsee')) return lineColors['S3-wannsee'];
|
if(lineName.toLowerCase().includes('wannsee')) return lineColors['S3-wannsee'];
|
||||||
@@ -58,15 +53,11 @@ function getLineColor(lineName, product) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(lineColors[lineName]) return lineColors[lineName];
|
if(lineColors[lineName]) return lineColors[lineName];
|
||||||
|
|
||||||
if(product === 'suburban') return '#CD9C53';
|
if(product === 'suburban') return '#CD9C53';
|
||||||
|
|
||||||
if(product === 'subway') return '#7DAD4C';
|
if(product === 'subway') return '#7DAD4C';
|
||||||
|
|
||||||
return '#666';
|
return '#666';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erzeuge DivIcon mit farbiger Linie als Hintergrund
|
|
||||||
function createDivIcon(vehicle) {
|
function createDivIcon(vehicle) {
|
||||||
const product = vehicle.line?.product;
|
const product = vehicle.line?.product;
|
||||||
const lineName = vehicle.line?.name || '?';
|
const lineName = vehicle.line?.name || '?';
|
||||||
@@ -173,7 +164,14 @@ function locateAndLoad() {
|
|||||||
navigator.geolocation.getCurrentPosition(pos => {
|
navigator.geolocation.getCurrentPosition(pos => {
|
||||||
const { latitude, longitude } = pos.coords;
|
const { latitude, longitude } = pos.coords;
|
||||||
map.setView([latitude, longitude], 14);
|
map.setView([latitude, longitude], 14);
|
||||||
L.circle([latitude, longitude], { radius: 1000, color: 'blue', fillOpacity: 0.1 }).addTo(map);
|
|
||||||
|
const locationIcon = L.divIcon({
|
||||||
|
className: 'user-location-icon',
|
||||||
|
iconSize: [12, 12],
|
||||||
|
iconAnchor: [6, 6]
|
||||||
|
});
|
||||||
|
|
||||||
|
L.marker([latitude, longitude], { icon: locationIcon }).addTo(map);
|
||||||
loadVehicles();
|
loadVehicles();
|
||||||
}, () => {
|
}, () => {
|
||||||
map.setView([52.52, 13.405], 13);
|
map.setView([52.52, 13.405], 13);
|
||||||
|
|||||||
Reference in new issue
Block a user