diff --git a/components/MapComponent.js b/components/MapComponent.js index add750d65..4451db82b 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -613,7 +613,7 @@ const MapComponent = ({ locations, onLocationUpdate }) => { // serverIP 10.10.0.13 idMap=10 idUser=485 const serverURL = "http://10.10.0.13"; const c = 10; // Beispielwert für idMap - const user = 483; // Beispielwert für idUser + const user = 486; // Beispielwert für idUser const fetchUserRights = async () => { try { @@ -969,20 +969,17 @@ const MapComponent = ({ locations, onLocationUpdate }) => { useEffect(() => { if (map && poiLayerRef.current && isPoiTypLoaded) { - // Entfernen Sie die bestehende Ebene und erstellen Sie eine neue map.removeLayer(poiLayerRef.current); poiLayerRef.current = new L.LayerGroup().addTo(map); - // Fügen Sie die aktualisierten Marker hinzu locations.forEach(async (location) => { const { latitude, longitude } = parsePoint(location.position); - const poiTypName = poiTypMap.get(location.idPoiTyp) || "Unbekannt "; - //console.log("poiTypName in poiLayer:", poiTypName); - //console.log("location.idPoiTyp poiLayer:", location.idPoiTyp); - //console.log("location.idPoiTyp poiLayer:", location); - //console.log("location.idPoiTyp:", location.idPoiTyp); - + const poiTypName = poiTypMap.get(location.idPoiTyp) || "Unbekannt"; const deviceName = await fetchDeviceNameById(location.idLD); + + // Check if user has the right to drag the marker + const canDrag = userRights ? userRights.includes(56) : false; // Check if userRights is not null before using includes + const marker = L.marker([latitude, longitude], { icon: L.icon({ iconUrl: `/img/icons/pois/poi-marker-icon-${location.idPoiTyp}.png`, @@ -990,74 +987,67 @@ const MapComponent = ({ locations, onLocationUpdate }) => { iconAnchor: [12, 41], popupAnchor: [1, -34], }), - draggable: true, + draggable: canDrag, // Set draggable based on permission id: location.idPoi, }).bindContextMenu({ contextmenu: true, contextmenuWidth: 140, contextmenuItems: [ { - text: "POI Bearbeiten", //git stash save "POI Bearbeiten" - + text: "POI Bearbeiten", icon: "/img/poi-edit.png", callback: () => handleEditPoi(marker), }, ], }); - //console.log("location.idPoi:", location); - // Popup konfigurieren marker.bindPopup(` -