fix: Area-Marker (Bereiche) können jetzt nur noch verschoben werden, wenn in localStorage der Wert "editMode" auf "true" gesetzt ist. Andernfalls sind sie nicht verschiebbar.
This commit is contained in:
@@ -71,10 +71,11 @@ const useAreaMarkersLayer = (map, oms, apiUrl, onUpdateSuccess) => {
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
const editMode = localStorage.getItem("editMode") === "true";
|
||||
const markers = data.map(item => {
|
||||
const marker = L.marker([item.x, item.y], {
|
||||
icon: customIcon,
|
||||
draggable: true,
|
||||
draggable: editMode,
|
||||
customType: "areaMarker",
|
||||
});
|
||||
|
||||
@@ -88,24 +89,26 @@ const useAreaMarkersLayer = (map, oms, apiUrl, onUpdateSuccess) => {
|
||||
}
|
||||
);
|
||||
|
||||
marker.on("dragend", async e => {
|
||||
const { lat, lng } = e.target.getLatLng();
|
||||
try {
|
||||
await dispatch(
|
||||
updateAreaThunk({
|
||||
idLocation: item.idLocation,
|
||||
idMap: item.idMaps,
|
||||
newCoords: { x: lat, y: lng },
|
||||
})
|
||||
).unwrap();
|
||||
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
|
||||
console.log("✔️ Koordinaten erfolgreich aktualisiert:", { lat, lng });
|
||||
if (editMode) {
|
||||
marker.on("dragend", async e => {
|
||||
const { lat, lng } = e.target.getLatLng();
|
||||
try {
|
||||
await dispatch(
|
||||
updateAreaThunk({
|
||||
idLocation: item.idLocation,
|
||||
idMap: item.idMaps,
|
||||
newCoords: { x: lat, y: lng },
|
||||
})
|
||||
).unwrap();
|
||||
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
|
||||
console.log("✔️ Koordinaten erfolgreich aktualisiert:", { lat, lng });
|
||||
}
|
||||
onUpdateSuccess?.(); // optionaler Callback
|
||||
} catch (error) {
|
||||
console.error("❌ Fehler beim Aktualisieren der Koordinaten:", error);
|
||||
}
|
||||
onUpdateSuccess?.(); // optionaler Callback
|
||||
} catch (error) {
|
||||
console.error("❌ Fehler beim Aktualisieren der Koordinaten:", error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return marker;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user