Use Recoil State Management
This commit is contained in:
@@ -7,18 +7,16 @@ import "leaflet-contextmenu";
|
|||||||
import * as config from "../config/config.js";
|
import * as config from "../config/config.js";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import "leaflet.smooth_marker_bouncing";
|
import "leaflet.smooth_marker_bouncing";
|
||||||
//import { OverlappingMarkerSpiderfier } from "../lib/OverlappingMarkerSpiderfier.js";
|
|
||||||
//import { OverlappingMarkerSpiderfier } from "../public/js/OverlappingMarkerSpiderfier.js";
|
|
||||||
import OverlappingMarkerSpiderfier from "overlapping-marker-spiderfier-leaflet";
|
import OverlappingMarkerSpiderfier from "overlapping-marker-spiderfier-leaflet";
|
||||||
import DataSheet from "../components/DataSheet";
|
import DataSheet from "../components/DataSheet";
|
||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { gisStationsStaticDistrictState } from '../features/gisStationState';
|
||||||
|
|
||||||
const MapComponent = ({ locations, onLocationUpdate }) => {
|
const MapComponent = ({ locations, onLocationUpdate }) => {
|
||||||
const mapRef = useRef(null); // Referenz auf das DIV-Element der Karte
|
const mapRef = useRef(null); // Referenz auf das DIV-Element der Karte
|
||||||
const [map, setMap] = useState(null); // Zustand der Karteninstanz
|
const [map, setMap] = useState(null); // Zustand der Karteninstanz
|
||||||
const [online, setOnline] = useState(navigator.onLine); // Zustand der Internetverbindung
|
const [online, setOnline] = useState(navigator.onLine); // Zustand der Internetverbindung
|
||||||
const [GisStationsStaticDistrict, setGisStationsStaticDistrict] = useState(
|
const [GisStationsStaticDistrict, setGisStationsStaticDistrict] = useRecoilState(gisStationsStaticDistrictState);
|
||||||
[]
|
|
||||||
); // Zustand für statische Daten
|
|
||||||
const [GisStationsStatusDistrict, setGisStationsStatusDistrict] = useState(
|
const [GisStationsStatusDistrict, setGisStationsStatusDistrict] = useState(
|
||||||
[]
|
[]
|
||||||
); // Zustand für Statusdaten
|
); // Zustand für Statusdaten
|
||||||
@@ -560,11 +558,11 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
|||||||
|
|
||||||
// Alte Marker entfernen, indem alle Marker, die durch OMS verwaltet werden, gelöscht werden
|
// Alte Marker entfernen, indem alle Marker, die durch OMS verwaltet werden, gelöscht werden
|
||||||
oms.clearMarkers();
|
oms.clearMarkers();
|
||||||
/* map.eachLayer((layer) => {
|
map.eachLayer((layer) => {
|
||||||
if (layer instanceof L.Marker) {
|
if (layer instanceof L.Marker) {
|
||||||
map.removeLayer(layer);
|
map.removeLayer(layer);
|
||||||
}
|
}
|
||||||
}); */
|
});
|
||||||
|
|
||||||
// Neue Marker für jede Station hinzufügen
|
// Neue Marker für jede Station hinzufügen
|
||||||
GisStationsStaticDistrict.forEach((station) => {
|
GisStationsStaticDistrict.forEach((station) => {
|
||||||
@@ -638,6 +636,28 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
|||||||
});
|
});
|
||||||
marker.bounce(3);
|
marker.bounce(3);
|
||||||
}
|
}
|
||||||
|
// Prüfen, ob der Name der Station "GMA Littwin (TEST)" entspricht
|
||||||
|
if (station.LD_Name === "GMA Littwin (TEST)") {
|
||||||
|
marker.bindTooltip(
|
||||||
|
`<div class="bg-white text-black p-2 border border-gray-300 rounded shadow">${station.Area_Name}</div>`,
|
||||||
|
{
|
||||||
|
permanent: true,
|
||||||
|
direction: "right",
|
||||||
|
opacity: 1, // Tooltip immer sichtbar
|
||||||
|
offset: L.point({ x: 10, y: 0 }),
|
||||||
|
}
|
||||||
|
).addTo(GMA);
|
||||||
|
} else {
|
||||||
|
marker.bindTooltip(
|
||||||
|
`<div class="bg-white text-black p-2 border border-gray-300 rounded shadow">${station.LD_Name}</div>`,
|
||||||
|
{
|
||||||
|
permanent: false,
|
||||||
|
direction: "right",
|
||||||
|
opacity: 0,
|
||||||
|
offset: L.point({ x: 10, y: 0 }),
|
||||||
|
}
|
||||||
|
).addTo(GMA);
|
||||||
|
}
|
||||||
// Marker zu OMS und der Karte hinzufügen
|
// Marker zu OMS und der Karte hinzufügen
|
||||||
oms.addMarker(marker);
|
oms.addMarker(marker);
|
||||||
marker.addTo(map).bindPopup(`
|
marker.addTo(map).bindPopup(`
|
||||||
@@ -648,7 +668,7 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
|||||||
${statusInfo}<br>
|
${statusInfo}<br>
|
||||||
`);
|
`);
|
||||||
let LocID = station.IdLocation;
|
let LocID = station.IdLocation;
|
||||||
marker
|
/* marker
|
||||||
.bindTooltip(
|
.bindTooltip(
|
||||||
`<div class="bg-white text-black p-2 border border-gray-300 rounded shadow">${LocID}</div>`,
|
`<div class="bg-white text-black p-2 border border-gray-300 rounded shadow">${LocID}</div>`,
|
||||||
{
|
{
|
||||||
@@ -658,8 +678,9 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
|||||||
offset: L.point({ x: 10, y: 0 }),
|
offset: L.point({ x: 10, y: 0 }),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.addTo(GMA);
|
.addTo(GMA); */
|
||||||
});
|
});
|
||||||
|
|
||||||
}, [map, oms, GisStationsStaticDistrict, GisStationsStatusDistrict]);
|
}, [map, oms, GisStationsStaticDistrict, GisStationsStatusDistrict]);
|
||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user