diff --git a/components/MapComponent.js b/components/MapComponent.js index 4bee4c469..c4d8614ae 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -2297,10 +2297,32 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { color: lineColors[lineData.idModul] || "#000000", }).addTo(map); + // Dynamisch generierter Tooltip-Inhalt + const matchingStatus = lineStatusData.find( + (stat) => + stat.IdLD === lineData.idLD && stat.Modul === lineData.idModul + ); + + const dynamicTooltipContent = matchingStatus + ? ` +
+
+ DpName: ${matchingStatus.DpName || "Unknown"} +
+
+ ModulName: ${matchingStatus.ModulName || "N/A"} +
+
+ Message: ${matchingStatus.Message || "N/A"} +
+
+ ` + : "Informationen oder Name der Linie"; + // Hinzufügen eines Tooltips - updatedPolyline.bindTooltip(tooltipContent, { - permanent: false, // true, wenn Sie möchten, dass der Tooltip immer sichtbar ist - direction: "auto", // Kann 'right', 'left', 'top' oder 'bottom' sein + updatedPolyline.bindTooltip(dynamicTooltipContent, { + permanent: false, + direction: "auto", }); updatedPolyline.on("mouseover", () => { @@ -2352,14 +2374,35 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { lineMarkers.push(marker); }); + // Dynamisch generierter Tooltip-Inhalt + const matchingStatus = lineStatusData.find( + (stat) => stat.IdLD === lineData.idLD && stat.Modul === lineData.idModul + ); + + const dynamicTooltipContent = matchingStatus + ? ` +
+
+ DpName: ${matchingStatus.DpName || "Unknown"} +
+
+ ModulName: ${matchingStatus.ModulName || "N/A"} +
+
+ Message: ${matchingStatus.Message || "N/A"} +
+
+ ` + : "Informationen oder Name der Linie"; + // Erstellen der initialen Polyline und Einrichten eines Tooltips const polyline = L.polyline(lineData.coordinates, { color: lineColors[lineData.idModul] || "#000000", }).addTo(map); - polyline.bindTooltip(tooltipContent, { - permanent: false, // true, wenn Sie möchten, dass der Tooltip immer sichtbar ist - direction: "auto", // Kann 'right', 'left', 'top' oder 'bottom' sein + polyline.bindTooltip(dynamicTooltipContent, { + permanent: false, + direction: "auto", }); polyline.on("mouseover", () => {