fix(map): entferne Start-, End- und Stützpunkt-Icons sofort beim Ausblenden der Kabelstrecken

- Alle Marker mit StartIcon, EndIcon und CircleIcon werden jetzt direkt entfernt, wenn die Kabelstrecken-Checkbox deaktiviert wird
- Kein Browser-Reload mehr nötig, Icons verschwinden sofort von der Karte
This commit is contained in:
ISA
2025-08-22 10:12:03 +02:00
parent f2a322a91b
commit a013c07394
5 changed files with 62 additions and 38 deletions

View File

@@ -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.342
NEXT_PUBLIC_APP_VERSION=1.1.343

View File

@@ -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.342
NEXT_PUBLIC_APP_VERSION=1.1.343

View File

@@ -10,6 +10,9 @@ import { InformationCircleIcon } from "@heroicons/react/20/solid";
import PoiUpdateModal from "@/components/pois/poiUpdateModal/PoiUpdateModal.js";
import { ToastContainer, toast } from "react-toastify";
import plusRoundIcon from "../icons/devices/overlapping/PlusRoundIcon.js";
import StartIcon from "@/components/gisPolylines/icons/StartIcon.js";
import EndIcon from "@/components/gisPolylines/icons/EndIcon.js";
import CircleIcon from "@/components/gisPolylines/icons/CircleIcon.js";
import { restoreMapSettings, checkOverlappingMarkers } from "../../utils/mapUtils.js";
import addItemsToMapContextMenu from "@/components/contextmenu/useMapContextMenu.js";
@@ -234,6 +237,26 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
// URL-Parameter extrahieren und kartenspezifische localStorage-Keys verwenden
useEffect(() => {
// Immer beim Umschalten der Kabelstrecken-Checkbox prüfen!
if (map) {
if (!polylineVisible) {
map.eachLayer(layer => {
// Entferne alle Marker mit StartIcon, EndIcon oder CircleIcon (Stützpunkt)
if (
layer instanceof L.Marker &&
layer.options &&
layer.options.icon &&
(layer.options.icon === StartIcon ||
layer.options.icon === EndIcon ||
layer.options.icon === CircleIcon)
) {
map.removeLayer(layer);
}
});
}
}
// Initialisierung der Layer-Visibility und Polyline-Redux-State nur beim Mount
if (typeof window !== "undefined") {
const params = new URLSearchParams(window.location.search);
const mapId = params.get("m");
const userId = params.get("u");
@@ -268,7 +291,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
// Redux Polyline Sichtbarkeit initialisieren (map/user spezifisch)
dispatch(initializePolylineFromLocalStorageThunk());
}
}, [dispatch]); // Nur einmal beim Mount ausführen
}
}, [dispatch, polylineVisible, map]);
useEffect(() => {
if (linesData && Array.isArray(linesData)) {
const transformed = linesData.map(item => ({

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "nodemap",
"version": "1.1.342",
"version": "1.1.343",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "nodemap",
"version": "1.1.342",
"version": "1.1.343",
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",

View File

@@ -1,6 +1,6 @@
{
"name": "nodemap",
"version": "1.1.342",
"version": "1.1.343",
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",