fix: Git Konflikte gelöst, jetzt geht mit der Anzeige von zwei Linien auf die Map
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
// components/MapComponent.js
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> neuer-branch
|
||||
import React, {
|
||||
useEffect,
|
||||
useRef,
|
||||
@@ -10,10 +7,6 @@ import React, {
|
||||
useMemo,
|
||||
useCallback,
|
||||
} from "react";
|
||||
<<<<<<< HEAD
|
||||
//import ReactDOM from "react-dom/client"; // Import from 'react-dom/client'
|
||||
=======
|
||||
>>>>>>> neuer-branch
|
||||
import { MapContainer, TileLayer, Polyline, LayerGroup } from "react-leaflet";
|
||||
|
||||
import L, { marker } from "leaflet";
|
||||
@@ -55,16 +48,7 @@ const plusRoundIcon = L.icon({
|
||||
});
|
||||
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
<<<<<<< HEAD
|
||||
/* const linePositions = lineCoordinates || [
|
||||
[52.505, 8],
|
||||
[52, 8.5],
|
||||
[51.5, 8],
|
||||
[52.505, 8],
|
||||
]; */
|
||||
=======
|
||||
const [menuItemAdded, setMenuItemAdded] = useState(false);
|
||||
>>>>>>> neuer-branch
|
||||
|
||||
const poiLayerVisible = useRecoilValue(poiLayerVisibleState);
|
||||
|
||||
@@ -150,8 +134,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const zoomTrigger = useRecoilValue(zoomTriggerState);
|
||||
const offlineTileLayer = "/mapTiles/{z}/{x}/{y}.png";
|
||||
//const onlineTileLayer = "/mapTiles/{z}/{x}/{y}.png";
|
||||
const onlineTileLayer = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
|
||||
//const onlineTileLayer = "http://localhost:3000/mapTiles/{z}/{x}/{y}.png"; //Talas_v5 Server
|
||||
//const onlineTileLayer = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
|
||||
const onlineTileLayer = "http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"; //Talas_v5 Server
|
||||
// Create map layers
|
||||
const TALAS = new L.layerGroup();
|
||||
const ECI = new L.layerGroup();
|
||||
@@ -168,12 +152,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const lineLayer = new L.LayerGroup();
|
||||
|
||||
const [gisSystemStaticLoaded, setGisSystemStaticLoaded] = useState(false);
|
||||
<<<<<<< HEAD
|
||||
const baseUrl = "http://localhost/talas5/devices/";
|
||||
=======
|
||||
const baseUrl = "http://10.10.0.13/talas5/devices/";
|
||||
//const baseUrl = "http://localhost/talas5/devices/";
|
||||
>>>>>>> neuer-branch
|
||||
const [isPoiTypLoaded, setIsPoiTypLoaded] = useState(false);
|
||||
const [poiTypMap, setPoiTypMap] = useState(new Map());
|
||||
const [showPopup, setShowPopup] = useState(false);
|
||||
@@ -186,15 +166,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
|
||||
const handleAddStation = (stationData) => {
|
||||
// Station-Daten speichern oder API-Aufruf durchführen
|
||||
<<<<<<< HEAD
|
||||
console.log("Neue Station:", userRights.includes(56));
|
||||
|
||||
console.log("Neue Station:", stationData);
|
||||
=======
|
||||
//console.log("Neue Station:", userRights.includes(56));
|
||||
|
||||
//console.log("Neue Station:", stationData);
|
||||
>>>>>>> neuer-branch
|
||||
setShowAddStationPopup(false);
|
||||
closePopup(); // Schließt das Popup nach dem Hinzufügen
|
||||
};
|
||||
@@ -366,11 +340,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
); // Keine Abhängigkeiten, da `hasRights` als Parameter übergeben wird */
|
||||
const addStationCallback = useCallback(
|
||||
(event) => {
|
||||
<<<<<<< HEAD
|
||||
console.log("Benutzerrechte zum Zeitpunkt des Aufrufs:", hasRights);
|
||||
=======
|
||||
//console.log("Benutzerrechte zum Zeitpunkt des Aufrufs:", hasRights);
|
||||
>>>>>>> neuer-branch
|
||||
if (hasRights) {
|
||||
setPopupCoordinates(event.latlng);
|
||||
setShowPopup(true);
|
||||
@@ -384,11 +354,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
});
|
||||
<<<<<<< HEAD
|
||||
console.log("Benutzer hat keine Berechtigung zum Hinzufügen.");
|
||||
=======
|
||||
console.error("Benutzer hat keine Berechtigung zum Hinzufügen.");
|
||||
>>>>>>> neuer-branch
|
||||
}
|
||||
},
|
||||
[hasRights]
|
||||
@@ -755,11 +721,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const port = url.port; // Gibt den Port zurück, leer wenn Standardport verwendet wird
|
||||
const protocol = url.protocol; // "http:" oder "https:"
|
||||
//const serverURL = `${protocol}//${hostname}`;
|
||||
<<<<<<< HEAD
|
||||
const serverURL = "http://localhost"; // weil ich keine API habe, ansonsten serverURL ist localhost(IP-Adresse)
|
||||
=======
|
||||
const serverURL = "http://10.10.0.13"; // weil ich keine API habe, ansonsten serverURL ist localhost(IP-Adresse)
|
||||
>>>>>>> neuer-branch
|
||||
//const serverURL = "http://localhost:3000";
|
||||
|
||||
const params = new URL(window.location.href).searchParams;
|
||||
@@ -781,26 +743,16 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const userRightsIds = rightsArray.map((right) => right.IdRight);
|
||||
setUserRights(userRightsIds); // Speichert die Rechte in den Zustand
|
||||
|
||||
<<<<<<< HEAD
|
||||
console.log("Benutzerrechte:", rightsArray);
|
||||
console.log("Benutzerrechte IDs:", userRightsIds);
|
||||
console.log("Benutzerrechte in if :", userRightsIds.includes(56));
|
||||
=======
|
||||
//console.log("Benutzerrechte:", rightsArray);
|
||||
//console.log("Benutzerrechte IDs:", userRightsIds);
|
||||
//console.log("Benutzerrechte in if :", userRightsIds.includes(56));
|
||||
>>>>>>> neuer-branch
|
||||
setHasRights(userRightsIds.includes(56));
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Abrufen der Benutzerrechte", error);
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
<<<<<<< HEAD
|
||||
console.log("Aktualisierter Status von hasRights: ", hasRights);
|
||||
=======
|
||||
//console.log("Aktualisierter Status von hasRights: ", hasRights);
|
||||
>>>>>>> neuer-branch
|
||||
}, [hasRights]); // Dieser Effekt läuft jedes Mal, wenn sich `hasRights` ändert.
|
||||
|
||||
// Überprüfen der Benutzerrechte beim Initialisieren der Komponente
|
||||
@@ -1181,21 +1133,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}).addTo(map);
|
||||
}
|
||||
}, [map]); */
|
||||
<<<<<<< HEAD
|
||||
const addItemsToMapContextMenu = () => {
|
||||
console.log("contextMenuItems hasRights:", hasRights);
|
||||
|
||||
map.contextmenu.addItem({
|
||||
text: "POI hinzufügen",
|
||||
icon: "img/add_station.png",
|
||||
className: "background-red",
|
||||
callback: (event) => addStationCallback(event, hasRights),
|
||||
});
|
||||
};
|
||||
//--------------------------------------------------
|
||||
useEffect(() => {
|
||||
if (map && poiLayerRef.current && isPoiTypLoaded) {
|
||||
=======
|
||||
|
||||
const addItemsToMapContextMenu = () => {
|
||||
if (!menuItemAdded) {
|
||||
@@ -1214,22 +1151,13 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (map && poiLayerRef.current && isPoiTypLoaded && !menuItemAdded) {
|
||||
>>>>>>> neuer-branch
|
||||
addItemsToMapContextMenu();
|
||||
}
|
||||
}, [
|
||||
map,
|
||||
<<<<<<< HEAD
|
||||
locations,
|
||||
onLocationUpdate,
|
||||
poiReadTrigger,
|
||||
isPoiTypLoaded,
|
||||
userRights,
|
||||
=======
|
||||
poiLayerRef,
|
||||
isPoiTypLoaded,
|
||||
menuItemAdded, // Hinzufügen zu den Abhängigkeiten, um den Effekt korrekt zu steuern
|
||||
>>>>>>> neuer-branch
|
||||
]);
|
||||
//------------------------------------------
|
||||
|
||||
@@ -1242,11 +1170,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const response = await fetch("/api/poi-icons");
|
||||
const data = await response.json();
|
||||
setPoiData(data);
|
||||
<<<<<<< HEAD
|
||||
console.log("poiData icons:", data);
|
||||
=======
|
||||
//console.log("poiData icons:", data);
|
||||
>>>>>>> neuer-branch
|
||||
};
|
||||
|
||||
fetchPoiData();
|
||||
@@ -1261,11 +1185,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const { latitude, longitude } = parsePoint(location.position);
|
||||
const poiTypName = poiTypMap.get(location.idPoiTyp) || "Unbekannt";
|
||||
const deviceName = await fetchDeviceNameById(location.idLD);
|
||||
<<<<<<< HEAD
|
||||
console.log("location.icon:", location);
|
||||
=======
|
||||
//console.log("location.icon:", location);
|
||||
>>>>>>> neuer-branch
|
||||
|
||||
// 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
|
||||
@@ -1774,7 +1694,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
|
||||
// Funktion zum Ein- und Ausblenden der TALAS-Marker basierend auf dem Zustand von mapLayersVisibility.TALAS
|
||||
|
||||
/* useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (!map || !talasMarkers) return;
|
||||
|
||||
const toggleLayer = (isVisible) => {
|
||||
@@ -1790,7 +1710,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
|
||||
// Apply visibility state to the TALAS layer
|
||||
toggleLayer(mapLayersVisibility.TALAS);
|
||||
}, [map, talasMarkers, mapLayersVisibility.TALAS]); */
|
||||
}, [map, talasMarkers, mapLayersVisibility.TALAS]);
|
||||
|
||||
//------------------------------------------ */
|
||||
// Funktion zum Ein- und Ausblenden der ECI-Marker basierend auf dem Zustand von mapLayersVisibility.ECI
|
||||
|
||||
Reference in New Issue
Block a user