refactor: .env.local und /config/urls.js aufgeräumt und initializeMap.js

This commit is contained in:
ISA
2024-12-12 13:36:15 +01:00
parent edf45e055d
commit 8a628c9f16
3 changed files with 7 additions and 9 deletions

View File

@@ -10,5 +10,5 @@ DB_PORT=3306
#NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
######################### Offline Karte
#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://127.0.0.1:3000/mapTiles/{z}/{x}/{y}.png"
NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"
#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"

View File

@@ -1,7 +1,7 @@
// /config/urls.js
// Dynamische Bestimmung der URLs basierend auf window.location.origin ohne Port
let BASE_URL, SERVER_URL, PROXY_TARGET, ONLINE_TILE_LAYER, OFFLINE_TILE_LAYER, MAP_TILES_LAYER;
let BASE_URL, SERVER_URL, PROXY_TARGET, OFFLINE_TILE_LAYER, MAP_TILES_LAYER;
if (typeof window !== "undefined") {
// Client-seitige Logik
@@ -11,14 +11,12 @@ if (typeof window !== "undefined") {
BASE_URL = `${originWithoutPort}/api`; // Dynamische Basis-URL
SERVER_URL = originWithoutPort; // Dynamisch ermittelt, ohne Port
PROXY_TARGET = `${originWithoutPort}:3000`; // Dynamisch für einen Proxy
//ONLINE_TILE_LAYER = `https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`;
//OFFLINE_TILE_LAYER = `https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`;
ONLINE_TILE_LAYER = "http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"; //Map von Talas_v5 Server
OFFLINE_TILE_LAYER = "http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"; //Map von Talas_v5 Server
//ONLINE_TILE_LAYER = `${originWithoutPort}:3000/mapTiles/{z}/{x}/{y}.png`;
//OFFLINE_TILE_LAYER = `${originWithoutPort}:3000/mapTiles/{z}/{x}/{y}.png`;
MAP_TILES_LAYER = ONLINE_TILE_LAYER; // Standardwert
//OFFLINE_TILE_LAYER = `https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`;
MAP_TILES_LAYER = OFFLINE_TILE_LAYER; // Standardwert
}
// Export der dynamischen Werte
export { BASE_URL, SERVER_URL, PROXY_TARGET, ONLINE_TILE_LAYER, OFFLINE_TILE_LAYER, MAP_TILES_LAYER };
export { BASE_URL, SERVER_URL, PROXY_TARGET, OFFLINE_TILE_LAYER, MAP_TILES_LAYER };

View File

@@ -64,7 +64,7 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
});
// Füge die Tile-Layer hinzu
L.tileLayer(urls.ONLINE_TILE_LAYER, {
L.tileLayer(urls.OFFLINE_TILE_LAYER, {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
}).addTo(initMap);