Fix: redrawPoline.js und POI hinzufgen auf die Karte in Kontextmenü

This commit is contained in:
ISA
2025-03-10 08:34:52 +01:00
parent 1f1ab4b818
commit b6c07bbc7d
7 changed files with 48 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
// /utils/markerUtils.js
import circleIcon from "../components/CircleIcon";
import { saveLineData, redrawPolyline } from "./mapUtils";
import { saveLineData } from "./mapUtils";
import { redrawPolyline } from "./mapUtils";
import L from "leaflet";
import { toast } from "react-toastify";
@@ -9,10 +10,7 @@ export const insertNewMarker = (closestPoints, newPoint, lineData, map) => {
icon: circleIcon,
draggable: true,
}).addTo(map);
lineData.coordinates.splice(closestPoints[2], 0, [
newPoint.lat,
newPoint.lng,
]);
lineData.coordinates.splice(closestPoints[2], 0, [newPoint.lat, newPoint.lng]);
// Hier direkt speichern nach Einfügen
saveLineData(lineData);
@@ -39,9 +37,7 @@ export const removeMarker = (marker, lineData, currentZoom, currentCenter) => {
//localStorage.setItem("mapCenter", JSON.stringify(currentCenter));
// Find the index of the coordinate that matches the marker's position
const index = lineData.coordinates.findIndex((coord) =>
L.latLng(coord[0], coord[1]).equals(marker.getLatLng())
);
const index = lineData.coordinates.findIndex((coord) => L.latLng(coord[0], coord[1]).equals(marker.getLatLng()));
if (index !== -1) {
// Remove the coordinate from the line data