fix: Geräte-Marker werden nur noch über LayerGroups verwaltet, doppelte Marker auf Karte verhindert
Geräte-Marker werden vor dem Hinzufügen aus LayerGroups entfernt und nur dort hinzugefügt Keine direkte .addTo(map) mehr für Geräte-Marker Debug-Ausgabe für Marker-Anzahl pro LayerGroup Problem mit mehrfachen Markern auf der Karte behoben
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
|
# 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
|
# basePath wird jetzt in public/config.json gepflegt
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.1.319
|
NEXT_PUBLIC_APP_VERSION=1.1.320
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=false
|
|||||||
# basePath wird jetzt in public/config.json gepflegt
|
# basePath wird jetzt in public/config.json gepflegt
|
||||||
|
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.1.319
|
NEXT_PUBLIC_APP_VERSION=1.1.320
|
||||||
|
|||||||
@@ -30,30 +30,44 @@ const useDynamicDeviceLayers = (map, GisSystemStatic, mapLayersVisibility, prior
|
|||||||
if (!map || GisSystemStatic.length === 0) return;
|
if (!map || GisSystemStatic.length === 0) return;
|
||||||
|
|
||||||
GisSystemStatic.forEach(({ Name, IdSystem }) => {
|
GisSystemStatic.forEach(({ Name, IdSystem }) => {
|
||||||
const key = `system-${IdSystem}`; // Einheitlicher Key
|
const key = `system-${IdSystem}`;
|
||||||
|
// LayerGroup-Instanzierung und Bereinigung
|
||||||
if (!layerRefs.current[key]) {
|
if (layerRefs.current[key]) {
|
||||||
layerRefs.current[key] = new L.LayerGroup().addTo(map);
|
// Entferne alte LayerGroup von der Map, falls vorhanden
|
||||||
|
if (map.hasLayer(layerRefs.current[key])) {
|
||||||
|
map.removeLayer(layerRefs.current[key]);
|
||||||
|
}
|
||||||
|
layerRefs.current[key].clearLayers();
|
||||||
}
|
}
|
||||||
|
// Neue oder wiederverwendete LayerGroup anlegen und zur Map hinzufügen
|
||||||
|
if (!layerRefs.current[key]) {
|
||||||
|
layerRefs.current[key] = new L.LayerGroup();
|
||||||
|
}
|
||||||
|
layerRefs.current[key].addTo(map);
|
||||||
|
// Debug-Ausgabe
|
||||||
|
/* console.log(
|
||||||
|
`[DeviceLayers] LayerGroup für ${key} auf Map hinzugefügt. Aktuelle LayerGroups:`,
|
||||||
|
Object.keys(layerRefs.current)
|
||||||
|
); */
|
||||||
|
|
||||||
createAndSetDevices(
|
createAndSetDevices(
|
||||||
IdSystem,
|
IdSystem,
|
||||||
newMarkers => {
|
newMarkers => {
|
||||||
const oldMarkers = markerStates[key];
|
// Füge neue Marker der LayerGroup hinzu (nur Geräte-Marker)
|
||||||
|
if (layerRefs.current[key]) {
|
||||||
// Entferne alte Marker aus Karte und OMS
|
// Entferne alle Marker aus der LayerGroup, bevor neue hinzugefügt werden
|
||||||
if (oldMarkers && Array.isArray(oldMarkers)) {
|
layerRefs.current[key].clearLayers();
|
||||||
oldMarkers.forEach(marker => {
|
newMarkers.forEach(marker => {
|
||||||
if (map.hasLayer(marker)) {
|
// Nur LayerGroup verwenden, nicht direkt auf map
|
||||||
map.removeLayer(marker);
|
marker.addTo(layerRefs.current[key]);
|
||||||
}
|
|
||||||
if (oms) {
|
|
||||||
oms.removeMarker(marker);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
// Debug: Anzahl Marker in LayerGroup
|
||||||
|
console.log(
|
||||||
|
`[DeviceLayers] ${
|
||||||
|
layerRefs.current[key].getLayers().length
|
||||||
|
} Marker in LayerGroup für ${key}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Neue Marker setzen
|
|
||||||
setMarkerStates(prev => ({ ...prev, [key]: newMarkers }));
|
setMarkerStates(prev => ({ ...prev, [key]: newMarkers }));
|
||||||
},
|
},
|
||||||
GisSystemStatic,
|
GisSystemStatic,
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.319",
|
"version": "1.1.320",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.319",
|
"version": "1.1.320",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.319",
|
"version": "1.1.320",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user