Popup statt Modal für die Koordinaten kopieren

This commit is contained in:
ismailali1553
2025-01-17 20:20:53 +01:00
parent f69f54dba9
commit e9abcacf1e
3 changed files with 68 additions and 27 deletions

View File

@@ -2,12 +2,13 @@
import { toast } from "react-toastify";
import { zoomIn, zoomOut, centerHere } from "../utils/zoomAndCenterUtils";
const addItemsToMapContextMenu = (map, menuItemAdded, setMenuItemAdded, openModalWithCoordinates, hasRights, setShowPopup, setPopupCoordinates) => {
// components/useMapContextMenu.js
const addItemsToMapContextMenu = (map, menuItemAdded, setMenuItemAdded, openPopupWithCoordinates) => {
if (!menuItemAdded && map && map.contextmenu) {
map.contextmenu.addItem({
text: "Koordinaten anzeigen",
icon: "img/not_listed_location.png",
callback: openModalWithCoordinates,
callback: openPopupWithCoordinates, // Aufruf des Popup-Callbacks
});
map.contextmenu.addItem({ separator: true });
@@ -15,39 +16,27 @@ const addItemsToMapContextMenu = (map, menuItemAdded, setMenuItemAdded, openModa
map.contextmenu.addItem({
text: "Reinzoomen",
icon: "img/zoom_in.png",
callback: (e) => zoomIn(e, map),
callback: (e) => {
map.setZoom(map.getZoom() + 1);
},
});
map.contextmenu.addItem({
text: "Rauszoomen",
icon: "img/zoom_out.png",
callback: () => zoomOut(map),
callback: () => {
map.setZoom(map.getZoom() - 1);
},
});
map.contextmenu.addItem({
text: "Hier zentrieren",
icon: "img/center_focus.png",
callback: (e) => centerHere(e, map),
callback: (e) => {
map.panTo(e.latlng);
},
});
if (localStorage.getItem("editMode") === "true") {
map.contextmenu.addItem({ separator: true });
map.contextmenu.addItem({
text: "POI hinzufügen",
icon: "img/add_station.png",
className: "background-red",
callback: (event) => {
const editMode = localStorage.getItem("editMode") === "true";
if (editMode && hasRights) {
setPopupCoordinates(event.latlng);
setShowPopup(true);
} else {
toast.error("Benutzer hat keine Berechtigung zum Hinzufügen.");
}
},
});
}
setMenuItemAdded(true);
}
};