From 6c60700b7c8d605d9e71f093dd02d6aedb59f399 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 10 Jul 2024 08:27:00 +0200 Subject: [PATCH] feat: Create /config/layers.js module for Separate of Consern --- components/MapComponent.js | 44 +++++++++++++------------------------- config/config.js | 12 +++++------ config/layers.js | 17 +++++++++++++++ config/settings.js | 4 ++++ 4 files changed, 42 insertions(+), 35 deletions(-) create mode 100644 config/layers.js create mode 100644 config/settings.js diff --git a/components/MapComponent.js b/components/MapComponent.js index 5dfa8ef31..7db8c5d2c 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -74,6 +74,8 @@ import { addContextMenuToMarker, openInNewTab, } from "../utils/contextMenuUtils.js"; +import * as settings from "../config/settings.js"; +import * as layers from "../config/layers.js"; //--------------------------------------------------------------------- //-------------------- MapComponent ----------------------------------- @@ -146,19 +148,19 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const onlineTileLayer = urls.ONLINE_TILE_LAYER; //Talas_v5 Server // Create map layers - const TALAS = config.MAP_LAYERS.TALAS; - const ECI = config.MAP_LAYERS.ECI; - const ULAF = config.MAP_LAYERS.ULAF; - const GSMModem = config.MAP_LAYERS.GSMModem; - const CiscoRouter = config.MAP_LAYERS.CiscoRouter; - const WAGO = config.MAP_LAYERS.WAGO; - const Siemens = config.MAP_LAYERS.Siemens; - const OTDR = config.MAP_LAYERS.OTDR; - const WDM = config.MAP_LAYERS.WDM; - const GMA = config.MAP_LAYERS.GMA; - const Sonstige = config.MAP_LAYERS.Sonstige; - const TALASICL = config.MAP_LAYERS.TALASICL; - const lineLayer = config.MAP_LAYERS.lineLayer; + const TALAS = layers.MAP_LAYERS.TALAS; + const ECI = layers.MAP_LAYERS.ECI; + const ULAF = layers.MAP_LAYERS.ULAF; + const GSMModem = layers.MAP_LAYERS.GSMModem; + const CiscoRouter = layers.MAP_LAYERS.CiscoRouter; + const WAGO = layers.MAP_LAYERS.WAGO; + const Siemens = layers.MAP_LAYERS.Siemens; + const OTDR = layers.MAP_LAYERS.OTDR; + const WDM = layers.MAP_LAYERS.WDM; + const GMA = layers.MAP_LAYERS.GMA; + const Sonstige = layers.MAP_LAYERS.Sonstige; + const TALASICL = layers.MAP_LAYERS.TALASICL; + const lineLayer = layers.MAP_LAYERS.lineLayer; const [gisSystemStaticLoaded, setGisSystemStaticLoaded] = useState(false); @@ -2108,22 +2110,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //--------------------------------------------------------- //-------------------------Funktionen-------------------------------- - // Call this function on page load to restore zoom and center - /* function restoreMapSettings() { - const savedZoom = localStorage.getItem("mapZoom"); - const savedCenter = localStorage.getItem("mapCenter"); - - if (savedZoom && savedCenter) { - try { - const centerCoords = JSON.parse(savedCenter); - map.setView(centerCoords, parseInt(savedZoom)); - } catch (e) { - console.error("Error parsing stored map center:", e); - map.setView([53.111111, 8.4625], 12); // Standardkoordinaten und -zoom - } - } - } */ - // Call restoreMapSettings when the map is initialized useEffect(() => { if (map) { diff --git a/config/config.js b/config/config.js index 9c176f062..454b5058b 100644 --- a/config/config.js +++ b/config/config.js @@ -1,19 +1,19 @@ // /config/config.js // BASE_URL für Station öffnen in neuer tab und gleicher tab, im localhost gab es keine Probleme mit der Frame -export const BASE_URL = "http://10.10.0.13/talas5/devices/"; +//export const BASE_URL = "http://10.10.0.13/talas5/devices/"; //const baseUrl = "http://localhost:3000/talas5/devices/"; //const baseUrl = "http://192.168.10.14/talas5/devices/"; //---- //Talas_v5 Server //export const OFFLINE_TILE_LAYER = "/mapTiles/{z}/{x}/{y}.png"; // wenn im von localhost also selben Server die Karte angezeigt wird -export const OFFLINE_TILE_LAYER = "/mapTiles/{z}/{x}/{y}.png"; +//export const OFFLINE_TILE_LAYER = "/mapTiles/{z}/{x}/{y}.png"; //const onlineTileLayer = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"; -export const ONLINE_TILE_LAYER = - "http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"; //Talas_v5 Server +/* export const ONLINE_TILE_LAYER = + "http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"; //Talas_v5 Server */ // Create map layers -export const MAP_LAYERS = { +/* export const MAP_LAYERS = { TALAS: new L.layerGroup(), ECI: new L.layerGroup(), ULAF: new L.layerGroup(), @@ -27,7 +27,7 @@ export const MAP_LAYERS = { Sonstige: new L.layerGroup(), TALASICL: new L.layerGroup(), lineLayer: new L.LayerGroup(), -}; +}; */ // Definieren der grundlegenden Umgebungseinstellungen und Konfigurationen der Karte const mapVersion = "0.5.3"; // Die Version der verwendeten Karte const standardSideMenu = true; // Einstellung, ob ein standardmäßiges Seitenmenü verwendet wird diff --git a/config/layers.js b/config/layers.js new file mode 100644 index 000000000..30c0ebde7 --- /dev/null +++ b/config/layers.js @@ -0,0 +1,17 @@ +import L from "leaflet"; + +export const MAP_LAYERS = { + TALAS: new L.layerGroup(), + ECI: new L.layerGroup(), + ULAF: new L.layerGroup(), + GSMModem: new L.layerGroup(), + CiscoRouter: new L.layerGroup(), + WAGO: new L.layerGroup(), + Siemens: new L.layerGroup(), + OTDR: new L.layerGroup(), + WDM: new L.layerGroup(), + GMA: new L.layerGroup(), + Sonstige: new L.layerGroup(), + TALASICL: new L.layerGroup(), + lineLayer: new L.LayerGroup(), +}; diff --git a/config/settings.js b/config/settings.js new file mode 100644 index 000000000..30bc77720 --- /dev/null +++ b/config/settings.js @@ -0,0 +1,4 @@ +// Definieren der grundlegenden Umgebungseinstellungen und Konfigurationen der Karte +export const MAP_VERSION = "0.5.3"; +export const STANDARD_SIDE_MENU = true; +export const FULL_SIDE_MENU = false;