git commit -m "fix: Station öffnen im Kontextmenü für POIs deaktiviert"
This commit is contained in:
@@ -84,6 +84,7 @@ import useInitializeMap from "./hooks/useInitializeMap";
|
|||||||
import useLoadUserRights from "./hooks/useLoadUserRights";
|
import useLoadUserRights from "./hooks/useLoadUserRights";
|
||||||
import useFetchWebServiceMap from "./hooks/useFetchWebServiceMap";
|
import useFetchWebServiceMap from "./hooks/useFetchWebServiceMap";
|
||||||
import useFetchPoiData from "./hooks/useFetchPoiData.js";
|
import useFetchPoiData from "./hooks/useFetchPoiData.js";
|
||||||
|
import useRestoreMapSettings from "./hooks/useRestoreMapSettings";
|
||||||
|
|
||||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||||
const dispatch = useDispatch();
|
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([]);
|
const [poiData, setPoiData] = useState([]);
|
||||||
// POIs Popup Informationen anzeigen
|
// POIs Popup Informationen anzeigen
|
||||||
useFetchPoiData(setPoiTypMap, setPoiData);
|
useFetchPoiData(setPoiTypMap, setPoiData);
|
||||||
|
//Test in useEffect
|
||||||
useEffect(() => {
|
/* useEffect(() => {
|
||||||
console.log("📌 POI-Typ Map in MapComponent:", poiTypMap);
|
console.log("📌 POI-Typ Map in MapComponent:", poiTypMap);
|
||||||
console.log("📌 POI-Daten in MapComponent:", poiData);
|
console.log("📌 POI-Daten in MapComponent:", poiData);
|
||||||
}, [poiTypMap, poiData]);
|
}, [poiTypMap, poiData]); */
|
||||||
|
|
||||||
//--------------------------------------------
|
//--------------------------------------------
|
||||||
// POIs auf die Karte zeichnen
|
// POIs auf die Karte zeichnen
|
||||||
@@ -502,8 +502,11 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
|
|
||||||
//--------------------------------------------
|
//--------------------------------------------
|
||||||
//--------------------------------------------
|
//--------------------------------------------
|
||||||
|
useRestoreMapSettings(map);
|
||||||
|
//Test in useEffect
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (map) {
|
if (map) {
|
||||||
|
console.log("🗺️ Map-Einstellungen werden wiederhergestellt...");
|
||||||
restoreMapSettings(map);
|
restoreMapSettings(map);
|
||||||
}
|
}
|
||||||
}, [map]);
|
}, [map]);
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ const API_BASE_URL = process.env.NEXT_PUBLIC_API_PORT_3000; // API-URL aus .env.
|
|||||||
|
|
||||||
const useFetchPoiData = (setPoiTypMap, setPoiData) => {
|
const useFetchPoiData = (setPoiTypMap, setPoiData) => {
|
||||||
useEffect(() => {
|
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("✅ useFetchPoiData wurde gestartet...");
|
||||||
console.log(`🌍 API_BASE_URL: ${API_BASE_URL}`); // Debugging: Prüfen, ob die Umgebungsvariable korrekt geladen wird
|
// console.log(`🌍 API_BASE_URL: ${API_BASE_URL}`); // Debugging: Prüfen, ob die Umgebungsvariable korrekt geladen wird
|
||||||
|
|
||||||
const fetchPoiTypData = async () => {
|
const fetchPoiTypData = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -22,7 +22,7 @@ const useFetchPoiData = (setPoiTypMap, setPoiData) => {
|
|||||||
const map = new Map();
|
const map = new Map();
|
||||||
data.forEach((item) => map.set(item.idPoiTyp, item.name));
|
data.forEach((item) => map.set(item.idPoiTyp, item.name));
|
||||||
setPoiTypMap(map);
|
setPoiTypMap(map);
|
||||||
console.log("✅ POI-Typ-Daten erfolgreich geladen!");
|
//console.log("✅ POI-Typ-Daten erfolgreich geladen!");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ Fehler beim Abrufen der POI-Typ-Daten:", error);
|
console.error("❌ Fehler beim Abrufen der POI-Typ-Daten:", error);
|
||||||
}
|
}
|
||||||
@@ -30,14 +30,14 @@ const useFetchPoiData = (setPoiTypMap, setPoiData) => {
|
|||||||
|
|
||||||
const fetchPoiData = async () => {
|
const fetchPoiData = async () => {
|
||||||
try {
|
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`);
|
const response = await fetch(`${API_BASE_URL}/api/talas_v5_DB/pois/poi-icons`);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Netzwerkantwort war nicht ok, Status: ${response.status}`);
|
throw new Error(`Netzwerkantwort war nicht ok, Status: ${response.status}`);
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setPoiData(data);
|
setPoiData(data);
|
||||||
console.log("✅ POI-Icons erfolgreich geladen!", data);
|
//console.log("✅ POI-Icons erfolgreich geladen!", data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ Fehler beim Abrufen der POI-Daten:", error);
|
console.error("❌ Fehler beim Abrufen der POI-Daten:", error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,21 +21,21 @@ const useFetchWebServiceMap = (mapGisStationsStatusDistrictUrl, mapGisStationsMe
|
|||||||
};
|
};
|
||||||
|
|
||||||
// GIS Stations Status District abrufen
|
// 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);
|
await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
|
||||||
// console.log("✅ fetchGisStationsStatusDistrict erfolgreich!");
|
// console.log("✅ fetchGisStationsStatusDistrict erfolgreich!");
|
||||||
requestCount++;
|
requestCount++;
|
||||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||||
|
|
||||||
// GIS Stations Measurements abrufen
|
// GIS Stations Measurements abrufen
|
||||||
console.log("⏳ Abrufen von GIS Stations Measurements...");
|
//console.log("⏳ Abrufen von GIS Stations Measurements...");
|
||||||
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
|
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
|
||||||
// console.log("✅ fetchGisStationsMeasurements erfolgreich!");
|
// console.log("✅ fetchGisStationsMeasurements erfolgreich!");
|
||||||
requestCount++;
|
requestCount++;
|
||||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||||
|
|
||||||
// GIS System Static abrufen
|
// GIS System Static abrufen
|
||||||
console.log("⏳ Abrufen von GIS System Static...");
|
//console.log("⏳ Abrufen von GIS System Static...");
|
||||||
await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions);
|
await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions);
|
||||||
//console.log("✅ fetchGisSystemStatic erfolgreich!");
|
//console.log("✅ fetchGisSystemStatic erfolgreich!");
|
||||||
requestCount++;
|
requestCount++;
|
||||||
|
|||||||
12
components/mainComponent/hooks/useRestoreMapSettings.js
Normal file
12
components/mainComponent/hooks/useRestoreMapSettings.js
Normal 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;
|
||||||
@@ -72,7 +72,7 @@ const addItemsToMapContextMenu = (
|
|||||||
const editMode = localStorage.getItem("editMode") === "true";
|
const editMode = localStorage.getItem("editMode") === "true";
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
console.log("editMode localStorage:", localStorage.getItem("editMode"));
|
console.log("editMode localStorage:", localStorage.getItem("editMode"));
|
||||||
console.log("editMode:", editMode);
|
//console.log("editMode:", editMode);
|
||||||
|
|
||||||
map.contextmenu.addItem({
|
map.contextmenu.addItem({
|
||||||
text: "POI hinzufügen",
|
text: "POI hinzufügen",
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// /config/appVersion
|
// /config/appVersion
|
||||||
export const APP_VERSION = "1.1.52";
|
export const APP_VERSION = "1.1.53";
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
|
|||||||
text: "Station öffnen (Tab)",
|
text: "Station öffnen (Tab)",
|
||||||
icon: "/img/screen_new.png",
|
icon: "/img/screen_new.png",
|
||||||
callback: (e) => {
|
callback: (e) => {
|
||||||
|
const editMode = localStorage.getItem("editMode") === "true";
|
||||||
const clickedElement = e.relatedTarget;
|
const clickedElement = e.relatedTarget;
|
||||||
|
|
||||||
if (!clickedElement) {
|
if (!clickedElement) {
|
||||||
@@ -45,12 +46,18 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
|
|||||||
return;
|
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 {
|
try {
|
||||||
if (clickedElement instanceof L.Marker || clickedElement?.options?.link) {
|
if (clickedElement instanceof L.Marker || clickedElement?.options?.link) {
|
||||||
const link = "http://" + window.location.hostname + "/talas5/devices/" + clickedElement.options.link;
|
const link = "http://" + window.location.hostname + "/talas5/devices/" + clickedElement.options.link;
|
||||||
if (link) {
|
if (link) {
|
||||||
console.log("Opening link in a new tab:", 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 {
|
} else {
|
||||||
console.error("No link found in the Marker options.");
|
console.error("No link found in the Marker options.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user