Feature: Add interactive markers to polyline via context menu
This commit is contained in:
@@ -2481,12 +2481,13 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}
|
||||
|
||||
function updateMarkerPosition(newLatLng, lineData, marker) {
|
||||
const index = lineData.coordinates.findIndex(
|
||||
(coord) => coord === marker.getLatLng()
|
||||
const index = lineData.coordinates.findIndex((coord) =>
|
||||
L.latLng(coord[0], coord[1]).equals(marker.getLatLng())
|
||||
);
|
||||
if (index !== -1) {
|
||||
lineData.coordinates[index] = [newLatLng.lat, newLatLng.lng];
|
||||
drawPolyline(lineData);
|
||||
redrawPolyline(lineData, map);
|
||||
saveLineData(lineData); // Speichern der neuen Koordinaten nach dem Verschieben
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2513,7 +2514,17 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
newPoint.lat,
|
||||
newPoint.lng,
|
||||
]);
|
||||
|
||||
// Hier direkt speichern nach Einfügen
|
||||
saveLineData(lineData);
|
||||
|
||||
redrawPolyline(lineData, map);
|
||||
|
||||
// Event-Listener für das Verschieben des Markers hinzufügen
|
||||
newMarker.on("dragend", () => {
|
||||
updateMarkerPosition(newMarker.getLatLng(), lineData, newMarker);
|
||||
saveLineData(lineData); // Speichern der neuen Koordinaten nach dem Verschieben
|
||||
});
|
||||
}
|
||||
function redrawPolyline(lineData, map) {
|
||||
if (lineData.polyline) map.removeLayer(lineData.polyline);
|
||||
|
||||
Reference in New Issue
Block a user