diff --git a/components/CircleIcon.js b/components/CircleIcon.js new file mode 100644 index 000000000..4e29508aa --- /dev/null +++ b/components/CircleIcon.js @@ -0,0 +1,12 @@ +// /components/CircleIcon.js +import L from "leaflet"; +import "leaflet/dist/leaflet.css"; + +const circleIcon = L.divIcon({ + className: "custom-div-icon", + html: "
", + iconSize: [25, 25], + iconAnchor: [5, 5], +}); + +export default circleIcon; diff --git a/components/EndIcon.js b/components/EndIcon.js new file mode 100644 index 000000000..aee9541c8 --- /dev/null +++ b/components/EndIcon.js @@ -0,0 +1,9 @@ +import L from "leaflet"; +const endIcon = L.divIcon({ + className: "custom-end-icon", + html: "", // Blau für den Endpunkt + iconSize: [25, 25], + iconAnchor: [5, 5], +}); + +export default endIcon; diff --git a/components/MapComponent.js b/components/MapComponent.js index e56f23761..6f632ce95 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -39,12 +39,10 @@ import { set } from "lodash"; import { poiLayerVisibleState } from "../store/atoms/poiLayerVisible.js"; import { data } from "autoprefixer"; import plusRoundIcon from "./PlusRoundIcon.js"; - -import { - parsePoint, - determinePriority, - createAndSetMarkers, -} from "../utlis/utils.js"; +import { parsePoint, handleEditPoi, insertNewMarker } from "../utlis/utils.js"; +import circleIcon from "./CircleIcon"; +import startIcon from "./StartIcon"; +import endIcon from "./EndIcon"; //--------------------------------------------------------------------- //-------------------- MapComponent ----------------------------------- @@ -148,37 +146,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { }); }, []); // Lade die Berechtigungen beim Initialisieren der Komponente - const handleEditPoi = (marker) => { - // Prüfung, ob der Benutzer die notwendigen Rechte hat - if (!userRights || !userRights.includes(56)) { - toast.error("Benutzer hat keine Berechtigung zum Bearbeiten.", { - position: "top-center", - autoClose: 5000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, - }); - console.log("Benutzer hat keine Berechtigung zum Bearbeiten."); - return; // Beendet die Funktion frühzeitig, wenn keine Berechtigung vorliegt - } - - //console.log("Selected Marker ID (idPoi):", marker.options.idPoi); - //console.log("Selected Marker Description:", marker.options.description); - - setCurrentPoiData({ - idPoi: marker.options.id, - name: marker.options.name, - description: marker.options.description, - }); - //console.log("POI-Daten1:", currentPoiData); - - fetchPoiData(marker.options.id); - - setShowPoiUpdateModal(true); - }; - const fetchPoiData = async (idPoi) => { const response = await fetch( `/api/talas_v5_DB/pois/getPoiById?idPoi=${idPoi}` @@ -580,14 +547,14 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const [sonstigeMarkers, setSonstigeMarkers] = useState([]); //----------station.System === 200 const [ulafMarkers, setUlafMarkers] = useState([]); //------------------ no exist //-------------------------------------------------------------------------------- - /* const determinePriority = (iconPath) => { + const determinePriority = (iconPath) => { for (let priority of priorityConfig) { if (iconPath.includes(priority.name.toLowerCase())) { return priority.level; } } return 5; // Default priority (lowest) - }; */ + }; /* function determinePriority(iconPath) { if (iconPath.includes("critical")) return 1; // Highest priority if (iconPath.includes("critical")) { @@ -612,7 +579,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { return 5; // Default priority (lowest) } */ // Daten von einer externen Quelle laden - /* const createAndSetMarkers = async (systemId, setMarkersFunction) => { + const createAndSetMarkers = async (systemId, setMarkersFunction) => { try { const response1 = await fetch(config.mapGisStationsStaticDistrictUrl); const jsonResponse = await response1.json(); @@ -641,6 +608,10 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const priority = determinePriority(iconPath); const zIndexOffset = 100 * (5 - priority); // Adjusted for simplicity and positive values + /* console.log( + `Icon Path: ${iconPath}, Priority: ${priority}, zIndexOffset: ${zIndexOffset}` + ); */ + const marker = L.marker([station.X, station.Y], { icon: L.icon({ iconUrl: iconPath, @@ -689,7 +660,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { } catch (error) { console.error("Error fetching data: ", error); } - }; */ + }; //-------------------------------------------------------------------------------- const mapLayersVisibility = useRecoilValue(mapLayersState); @@ -2076,14 +2047,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { } }, [map, zoomTrigger]); - //--------------------------------------------------------- - /* useEffect(() => { - //console.log("Aktualisierung in MapComponent.js:", poiReadTrigger); - // Logik zur Aktualisierung der Map hier hinzufügen - // Beispiel: Daten neu laden oder aktualisieren - }, [poiReadTrigger]); */ - //--------------------------------------------------------- - //--------------------------------------------------------- useEffect(() => { if (map) { @@ -2197,21 +2160,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {