From c8a14ee87364fe5bbd5c010363c7aa7654247cb2 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 20 Aug 2025 15:52:56 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Polyline-Layer-Visibility=20reagiert=20j?= =?UTF-8?q?etzt=20zuverl=C3=A4ssig=20auf=20Redux-State?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - setupPolylines wird im useEffect asynchron aufgerufen - Marker und Polylinien werden erst nach Abschluss der async-Operation gesetzt - Sichtbarkeit der Kabelstrecken (Kabel-Layer) wird korrekt auf der Karte --- .env.development | 2 +- .env.production | 2 +- components/mainComponent/MapComponent.js | 113 ++++++++++++----------- package-lock.json | 4 +- package.json | 2 +- 5 files changed, 63 insertions(+), 60 deletions(-) diff --git a/.env.development b/.env.development index c963c3c2b..e8255d536 100644 --- a/.env.development +++ b/.env.development @@ -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.330 +NEXT_PUBLIC_APP_VERSION=1.1.331 diff --git a/.env.production b/.env.production index 0d084ddcd..455b96b44 100644 --- a/.env.production +++ b/.env.production @@ -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.330 +NEXT_PUBLIC_APP_VERSION=1.1.331 diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index 753f56780..a5fae8a21 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -380,69 +380,72 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { }); cleanupPolylinesForMemory(polylines, map); - // Setze neue Marker und Polylinien mit den aktuellen Daten - if (polylineVisible) { - const { markers: newMarkers, polylines: newPolylines } = setupPolylines( - map, - linePositions, - lineColors, - tooltipContents, - setNewCoords, - tempMarker, - currentZoom, - currentCenter, - polylineVisible // kommt aus Redux - ); + // Setze neue Marker und Polylinien mit den aktuellen Daten (asynchron!) + const updatePolylines = async () => { + if (polylineVisible) { + const { markers: newMarkers, polylines: newPolylines } = await setupPolylines( + map, + linePositions, + lineColors, + tooltipContents, + setNewCoords, + tempMarker, + currentZoom, + currentCenter, + polylineVisible // kommt aus Redux + ); - (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"; + (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"; - polyline.bindTooltip(tooltipContent, { - permanent: false, - direction: "auto", - sticky: true, - offset: [20, 0], - pane: "tooltipPane", - }); + polyline.bindTooltip(tooltipContent, { + permanent: false, + direction: "auto", + sticky: true, + offset: [20, 0], + pane: "tooltipPane", + }); - polyline.on("mouseover", e => { - const tooltip = polyline.getTooltip(); - if (tooltip) { - const mousePos = e.containerPoint; - const mapSize = map.getSize(); + polyline.on("mouseover", e => { + const tooltip = polyline.getTooltip(); + if (tooltip) { + const mousePos = e.containerPoint; + const mapSize = map.getSize(); - let direction = "right"; + let direction = "right"; - if (mousePos.x > mapSize.x - 100) { - direction = "left"; - } else if (mousePos.x < 100) { - direction = "right"; + if (mousePos.x > mapSize.x - 100) { + direction = "left"; + } else if (mousePos.x < 100) { + direction = "right"; + } + + if (mousePos.y > mapSize.y - 100) { + direction = "top"; + } else if (mousePos.y < 100) { + direction = "bottom"; + } + + tooltip.options.direction = direction; + polyline.openTooltip(e.latlng); } + }); - if (mousePos.y > mapSize.y - 100) { - direction = "top"; - } else if (mousePos.y < 100) { - direction = "bottom"; - } - - tooltip.options.direction = direction; - polyline.openTooltip(e.latlng); - } + polyline.on("mouseout", () => { + polyline.closeTooltip(); + }); }); - - polyline.on("mouseout", () => { - polyline.closeTooltip(); - }); - }); - cleanupMarkers(markers, oms); - setMarkers(newMarkers); - setPolylines(newPolylines); - } else { - cleanupPolylinesForMemory(polylines, map); - setPolylines([]); - } + cleanupMarkers(markers, oms); + setMarkers(newMarkers); + setPolylines(newPolylines); + } else { + cleanupPolylinesForMemory(polylines, map); + setPolylines([]); + } + }; + updatePolylines(); }, [ map, linePositions, diff --git a/package-lock.json b/package-lock.json index f78b42afb..43382901c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nodemap", - "version": "1.1.330", + "version": "1.1.331", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nodemap", - "version": "1.1.330", + "version": "1.1.331", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/package.json b/package.json index 4f292bf42..01361bcc2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodemap", - "version": "1.1.330", + "version": "1.1.331", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0",