feat: Lines bringToFront effect on mouse over
This commit is contained in:
@@ -2214,30 +2214,46 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
color: lineColors[lineData.idModul] || "#000000",
|
color: lineColors[lineData.idModul] || "#000000",
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
|
// Event-Handler für mouseover und mouseout erneut einrichten
|
||||||
|
updatedPolyline.on("mouseover", () => {
|
||||||
|
updatedPolyline.setStyle({ weight: 8 });
|
||||||
|
updatedPolyline.bringToFront();
|
||||||
|
});
|
||||||
|
updatedPolyline.on("mouseout", () => {
|
||||||
|
updatedPolyline.setStyle({ weight: 5 });
|
||||||
|
});
|
||||||
|
|
||||||
// Ersetzen der alten Polyline durch die neue
|
// Ersetzen der alten Polyline durch die neue
|
||||||
newPolylines[lineIndex].remove();
|
newPolylines[lineIndex].remove();
|
||||||
newPolylines[lineIndex] = updatedPolyline;
|
newPolylines[lineIndex] = updatedPolyline;
|
||||||
lineData.coordinates = newCoordinates; // Aktualisieren der Koordinaten im Zustand
|
lineData.coordinates = newCoordinates;
|
||||||
|
|
||||||
// Optional: Koordinaten auf dem Server aktualisieren
|
|
||||||
// ...
|
|
||||||
});
|
});
|
||||||
|
|
||||||
lineMarkers.push(marker);
|
lineMarkers.push(marker);
|
||||||
return marker;
|
return marker;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Erstellen der Polyline
|
||||||
const polyline = L.polyline(lineData.coordinates, {
|
const polyline = L.polyline(lineData.coordinates, {
|
||||||
color: lineColors[lineData.idModul] || "#000000",
|
color: lineColors[lineData.idModul] || "#000000",
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
|
// Einrichten der mouseover- und mouseout-Event-Handler
|
||||||
|
polyline.on("mouseover", () => {
|
||||||
|
polyline.setStyle({ weight: 8 });
|
||||||
|
polyline.bringToFront();
|
||||||
|
});
|
||||||
|
polyline.on("mouseout", () => {
|
||||||
|
polyline.setStyle({ weight: 5 });
|
||||||
|
});
|
||||||
|
|
||||||
newPolylines.push(polyline);
|
newPolylines.push(polyline);
|
||||||
newMarkers.push(...lineMarkers);
|
newMarkers.push(...lineMarkers);
|
||||||
});
|
});
|
||||||
|
|
||||||
setMarkers(newMarkers);
|
setMarkers(newMarkers);
|
||||||
setPolylines(newPolylines);
|
setPolylines(newPolylines);
|
||||||
}, [map, linePositions, lineColors]); // Achten Sie darauf, dass dieser Effekt läuft, wenn sich `map`, `linePositions` oder `lineColors` ändern
|
}, [map, linePositions, lineColors]);
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user