fix: leere Array
This commit is contained in:
@@ -24,4 +24,4 @@ NEXT_PUBLIC_USE_MOCKS=true
|
||||
# z.B. http://10.10.0.13/xyz/index.aspx -> basePath in config.json auf /xyz setzen
|
||||
# basePath wird jetzt in public/config.json gepflegt
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.326
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.327
|
||||
|
||||
@@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=false
|
||||
# basePath wird jetzt in public/config.json gepflegt
|
||||
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.326
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.327
|
||||
|
||||
@@ -57,7 +57,7 @@ const useDynamicDeviceLayers = (map, GisSystemStatic, mapLayersVisibility, prior
|
||||
if (layerRefs.current[key]) {
|
||||
// Entferne alle Marker aus der LayerGroup, bevor neue hinzugefügt werden
|
||||
layerRefs.current[key].clearLayers();
|
||||
newMarkers.forEach(marker => {
|
||||
(Array.isArray(newMarkers) ? newMarkers : []).forEach(marker => {
|
||||
// Nur LayerGroup verwenden, nicht direkt auf map
|
||||
marker.addTo(layerRefs.current[key]);
|
||||
});
|
||||
@@ -86,7 +86,7 @@ const useDynamicDeviceLayers = (map, GisSystemStatic, mapLayersVisibility, prior
|
||||
Object.entries(markerStates).forEach(([key, markers]) => {
|
||||
const isVisible = mapLayersVisibility[key] ?? true; // undefined = true
|
||||
|
||||
markers.forEach(marker => {
|
||||
(Array.isArray(markers) ? markers : []).forEach(marker => {
|
||||
const hasLayer = map.hasLayer(marker);
|
||||
|
||||
// Logik korrigiert:
|
||||
|
||||
@@ -375,7 +375,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}
|
||||
|
||||
// vorherige Marker & Polylinien vollständig bereinigen
|
||||
markers.forEach(marker => {
|
||||
(Array.isArray(markers) ? markers : []).forEach(marker => {
|
||||
marker.remove();
|
||||
});
|
||||
cleanupPolylinesForMemory(polylines, map);
|
||||
@@ -394,7 +394,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
polylineVisible // kommt aus Redux
|
||||
);
|
||||
|
||||
newPolylines.forEach((polyline, index) => {
|
||||
(Array.isArray(newPolylines) ? newPolylines : []).forEach((polyline, index) => {
|
||||
const tooltipContent =
|
||||
tooltipContents[`${linePositions[index].idLD}-${linePositions[index].idModul}`] ||
|
||||
"Die Linie ist noch nicht in Webservice vorhanden oder bekommt keine Daten";
|
||||
@@ -616,14 +616,14 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
// Entferne alle Marker aus der Karte
|
||||
if (!map) return; // Sicherstellen, dass map existiert
|
||||
|
||||
areaMarkers.forEach(marker => {
|
||||
(Array.isArray(areaMarkers) ? areaMarkers : []).forEach(marker => {
|
||||
if (map.hasLayer(marker)) {
|
||||
map.removeLayer(marker);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Wenn editMode aktiviert ist, füge die Marker hinzu und aktiviere Dragging
|
||||
areaMarkers.forEach(marker => {
|
||||
(Array.isArray(areaMarkers) ? areaMarkers : []).forEach(marker => {
|
||||
if (!map.hasLayer(marker)) {
|
||||
marker.addTo(map); // Layer hinzufügen
|
||||
}
|
||||
@@ -836,7 +836,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
useEffect(() => {
|
||||
if (poiTypStatus === "succeeded" && Array.isArray(poiTypData)) {
|
||||
const map = new Map();
|
||||
poiTypData.forEach(item => map.set(item.idPoiTyp, item.name));
|
||||
(Array.isArray(poiTypData) ? poiTypData : []).forEach(item =>
|
||||
map.set(item.idPoiTyp, item.name)
|
||||
);
|
||||
setPoiTypMap(map);
|
||||
}
|
||||
}, [poiTypData, poiTypStatus]);
|
||||
@@ -928,7 +930,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, [GisSystemStatic]);
|
||||
useEffect(() => {
|
||||
if (Array.isArray(GisSystemStatic)) {
|
||||
GisSystemStatic.forEach(system => {
|
||||
(Array.isArray(GisSystemStatic) ? GisSystemStatic : []).forEach(system => {
|
||||
const key = `system-${system.IdSystem}`;
|
||||
if (!(key in mapLayersVisibility)) {
|
||||
dispatch(setLayerVisibility({ key, value: true })); // Sichtbarkeit aktivieren
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "nodemap",
|
||||
"version": "1.1.326",
|
||||
"version": "1.1.327",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nodemap",
|
||||
"version": "1.1.326",
|
||||
"version": "1.1.327",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/styled": "^11.13.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nodemap",
|
||||
"version": "1.1.326",
|
||||
"version": "1.1.327",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/styled": "^11.13.0",
|
||||
|
||||
@@ -60,47 +60,58 @@ export const initializeMap = (
|
||||
mapContainer.innerHTML = "";
|
||||
}
|
||||
|
||||
// --- CONFIG LOADING ---
|
||||
let config = null;
|
||||
let tileLayerUrl = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
|
||||
let mapCenter = [53.111111, 8.4625];
|
||||
let mapZoom = 12;
|
||||
let minZoom = 5;
|
||||
let maxZoom = 15;
|
||||
let mapCenter = [53.111111, 8.4625];
|
||||
try {
|
||||
if (window && window.__tileSource && window.__tileSourceUrl) {
|
||||
tileLayerUrl = window.__tileSourceUrl;
|
||||
minZoom = window.__tileSourceMinZoom;
|
||||
maxZoom = window.__tileSourceMaxZoom;
|
||||
if (window && window.__leafletConfig) {
|
||||
config = window.__leafletConfig;
|
||||
} else {
|
||||
// Synchronous config fetch using XMLHttpRequest (since fetch is async)
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "/config.json", false); // false = synchronous
|
||||
xhr.send(null);
|
||||
if (xhr.status === 200) {
|
||||
const config = JSON.parse(xhr.responseText);
|
||||
if (config.tileSources && config.active && config.tileSources[config.active]) {
|
||||
const source = config.tileSources[config.active];
|
||||
tileLayerUrl = source.url;
|
||||
minZoom = source.minZoom;
|
||||
maxZoom = source.maxZoom;
|
||||
window.__tileSourceUrl = tileLayerUrl;
|
||||
window.__tileSourceMinZoom = minZoom;
|
||||
window.__tileSourceMaxZoom = maxZoom;
|
||||
if (source.center && Array.isArray(source.center) && source.center.length === 2) {
|
||||
mapCenter = source.center;
|
||||
} else if (config.center && Array.isArray(config.center) && config.center.length === 2) {
|
||||
mapCenter = config.center;
|
||||
}
|
||||
}
|
||||
config = JSON.parse(xhr.responseText);
|
||||
window.__leafletConfig = config;
|
||||
}
|
||||
}
|
||||
if (config) {
|
||||
// Tile source
|
||||
if (config.tileSources && config.active && config.tileSources[config.active]) {
|
||||
const tileSource = config.tileSources[config.active];
|
||||
tileLayerUrl = tileSource.url || tileLayerUrl;
|
||||
minZoom = tileSource.minZoom ?? minZoom;
|
||||
maxZoom = tileSource.maxZoom ?? maxZoom;
|
||||
}
|
||||
// Center
|
||||
if (Array.isArray(config.center)) {
|
||||
mapCenter = config.center;
|
||||
}
|
||||
// Zoom (optional, fallback to 12)
|
||||
if (typeof config.zoom === "number") {
|
||||
mapZoom = config.zoom;
|
||||
}
|
||||
// minZoom/maxZoom global fallback
|
||||
if (typeof config.minZoom === "number") {
|
||||
minZoom = config.minZoom;
|
||||
}
|
||||
if (typeof config.maxZoom === "number") {
|
||||
maxZoom = config.maxZoom;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// Fallback bleibt OSM
|
||||
// Fallback bleibt OSM und Defaults
|
||||
}
|
||||
|
||||
let initMap;
|
||||
try {
|
||||
initMap = L.map(mapContainer, {
|
||||
center: mapCenter,
|
||||
zoom: minZoom,
|
||||
zoom: mapZoom,
|
||||
minZoom: minZoom,
|
||||
maxZoom: maxZoom,
|
||||
zoomControl: false,
|
||||
|
||||
Reference in New Issue
Block a user