feat: Marker hinzufügen und Marker entfernen in PolyLines und der currentZoom funktioniert

This commit is contained in:
ISA
2024-07-11 10:11:20 +02:00
parent 3ea4ce99b5
commit 0079664dfb
2 changed files with 15 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ export const insertNewMarker = (closestPoints, newPoint, lineData, map) => {
// Event-Listener für das Verschieben des Markers hinzufügen
newMarker.on("dragend", () => {
const newCoords = newMarker.getLatLng();
setNewCoords(newCoords);
const newCoordinates = [...lineData.coordinates];
newCoordinates[closestPoints[2]] = [newCoords.lat, newCoords.lng];
lineData.coordinates = newCoordinates;
@@ -66,8 +67,8 @@ export const handleEditPoi = (
export const removeMarker = (marker, lineData, currentZoom, currentCenter) => {
// Save zoom and center to localStorage
localStorage.setItem("mapZoom", currentZoom);
localStorage.setItem("mapCenter", JSON.stringify(currentCenter));
//localStorage.setItem("mapZoom", currentZoom);
//localStorage.setItem("mapCenter", JSON.stringify(currentCenter));
// Find the index of the coordinate that matches the marker's position
const index = lineData.coordinates.findIndex((coord) =>