git commit -m "fix: Station öffnen im Kontextmenü für POIs deaktiviert"

This commit is contained in:
ISA
2025-03-11 12:05:45 +01:00
parent 750e8fa6e5
commit 1444a24244
7 changed files with 38 additions and 16 deletions

View File

@@ -84,6 +84,7 @@ import useInitializeMap from "./hooks/useInitializeMap";
import useLoadUserRights from "./hooks/useLoadUserRights";
import useFetchWebServiceMap from "./hooks/useFetchWebServiceMap";
import useFetchPoiData from "./hooks/useFetchPoiData.js";
import useRestoreMapSettings from "./hooks/useRestoreMapSettings";
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
const dispatch = useDispatch();
@@ -292,15 +293,14 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
}, []);
//--------------------------------------------
//const poiData = useFetchPoiData("/api/talas_v5_DB/pois/poi-icons");
const [poiData, setPoiData] = useState([]);
// POIs Popup Informationen anzeigen
useFetchPoiData(setPoiTypMap, setPoiData);
useEffect(() => {
//Test in useEffect
/* useEffect(() => {
console.log("📌 POI-Typ Map in MapComponent:", poiTypMap);
console.log("📌 POI-Daten in MapComponent:", poiData);
}, [poiTypMap, poiData]);
}, [poiTypMap, poiData]); */
//--------------------------------------------
// POIs auf die Karte zeichnen
@@ -502,8 +502,11 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//--------------------------------------------
//--------------------------------------------
useRestoreMapSettings(map);
//Test in useEffect
useEffect(() => {
if (map) {
console.log("🗺️ Map-Einstellungen werden wiederhergestellt...");
restoreMapSettings(map);
}
}, [map]);

View File

@@ -5,10 +5,10 @@ const API_BASE_URL = process.env.NEXT_PUBLIC_API_PORT_3000; // API-URL aus .env.
const useFetchPoiData = (setPoiTypMap, setPoiData) => {
useEffect(() => {
console.log(`🌍 API_BASE_URL aus .env.local: ${API_BASE_URL}`);
//console.log(`🌍 API_BASE_URL aus .env.local: ${API_BASE_URL}`);
console.log("✅ useFetchPoiData wurde gestartet...");
console.log(`🌍 API_BASE_URL: ${API_BASE_URL}`); // Debugging: Prüfen, ob die Umgebungsvariable korrekt geladen wird
//console.log("✅ useFetchPoiData wurde gestartet...");
// console.log(`🌍 API_BASE_URL: ${API_BASE_URL}`); // Debugging: Prüfen, ob die Umgebungsvariable korrekt geladen wird
const fetchPoiTypData = async () => {
try {
@@ -22,7 +22,7 @@ const useFetchPoiData = (setPoiTypMap, setPoiData) => {
const map = new Map();
data.forEach((item) => map.set(item.idPoiTyp, item.name));
setPoiTypMap(map);
console.log("✅ POI-Typ-Daten erfolgreich geladen!");
//console.log("✅ POI-Typ-Daten erfolgreich geladen!");
} catch (error) {
console.error("❌ Fehler beim Abrufen der POI-Typ-Daten:", error);
}
@@ -30,14 +30,14 @@ const useFetchPoiData = (setPoiTypMap, setPoiData) => {
const fetchPoiData = async () => {
try {
console.log("📡 Lade POI-Icons...");
//console.log("📡 Lade POI-Icons...");
const response = await fetch(`${API_BASE_URL}/api/talas_v5_DB/pois/poi-icons`);
if (!response.ok) {
throw new Error(`Netzwerkantwort war nicht ok, Status: ${response.status}`);
}
const data = await response.json();
setPoiData(data);
console.log("✅ POI-Icons erfolgreich geladen!", data);
//console.log("✅ POI-Icons erfolgreich geladen!", data);
} catch (error) {
console.error("❌ Fehler beim Abrufen der POI-Daten:", error);
}

View File

@@ -21,21 +21,21 @@ const useFetchWebServiceMap = (mapGisStationsStatusDistrictUrl, mapGisStationsMe
};
// GIS Stations Status District abrufen
console.log("⏳ Abrufen von GIS Stations Status District...");
//console.log("⏳ Abrufen von GIS Stations Status District...");
await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
// console.log("✅ fetchGisStationsStatusDistrict erfolgreich!");
requestCount++;
localStorage.setItem("fetchWebServiceMap", requestCount);
// GIS Stations Measurements abrufen
console.log("⏳ Abrufen von GIS Stations Measurements...");
//console.log("⏳ Abrufen von GIS Stations Measurements...");
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
// console.log("✅ fetchGisStationsMeasurements erfolgreich!");
requestCount++;
localStorage.setItem("fetchWebServiceMap", requestCount);
// GIS System Static abrufen
console.log("⏳ Abrufen von GIS System Static...");
//console.log("⏳ Abrufen von GIS System Static...");
await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions);
//console.log("✅ fetchGisSystemStatic erfolgreich!");
requestCount++;

View File

@@ -0,0 +1,12 @@
import { useEffect } from "react";
import { restoreMapSettings } from "../../../utils/mapUtils.js"; // Stelle sicher, dass der Pfad korrekt ist
const useRestoreMapSettings = (map) => {
useEffect(() => {
if (map) {
restoreMapSettings(map);
}
}, [map]);
};
export default useRestoreMapSettings;

View File

@@ -72,7 +72,7 @@ const addItemsToMapContextMenu = (
const editMode = localStorage.getItem("editMode") === "true";
if (editMode) {
console.log("editMode localStorage:", localStorage.getItem("editMode"));
console.log("editMode:", editMode);
//console.log("editMode:", editMode);
map.contextmenu.addItem({
text: "POI hinzufügen",

View File

@@ -1,2 +1,2 @@
// /config/appVersion
export const APP_VERSION = "1.1.52";
export const APP_VERSION = "1.1.53";

View File

@@ -38,6 +38,7 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
text: "Station öffnen (Tab)",
icon: "/img/screen_new.png",
callback: (e) => {
const editMode = localStorage.getItem("editMode") === "true";
const clickedElement = e.relatedTarget;
if (!clickedElement) {
@@ -45,12 +46,18 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
return;
}
// Prüfen, ob es ein POI ist (POIs haben idPoi in den Optionen)
if (clickedElement instanceof L.Marker && clickedElement.options?.idPoi) {
console.log("POI erkannt - Station öffnen deaktiviert.");
return; // Keine Aktion ausführen
}
try {
if (clickedElement instanceof L.Marker || clickedElement?.options?.link) {
const link = "http://" + window.location.hostname + "/talas5/devices/" + clickedElement.options.link;
if (link) {
console.log("Opening link in a new tab:", link);
window.open(link, "_blank");
//window.open(link, "_blank"); POI-Link öffnen in neuem Tab
} else {
console.error("No link found in the Marker options.");
}