Popup statt Modal für die Koordinaten kopieren
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user