fix: Bereich ausgewählt dann könnte nicht mit der Maus die Kartenansicht verschieben

This commit is contained in:
ISA
2024-07-15 09:42:06 +02:00
parent cee8b44e59
commit 29eb3e8192
2 changed files with 51 additions and 8 deletions

View File

@@ -704,14 +704,14 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
callback: showCoordinates,
},
"-", // Divider
/* { text: "Reinzoomen", icon: "img/zoom_in.png", callback: zoomIn },
{ text: "Reinzoomen", icon: "img/zoom_in.png", callback: zoomIn },
{ text: "Rauszoomen", icon: "img/zoom_out.png", callback: zoomOut },
{
text: "Hier zentrieren",
icon: "img/center_focus.png",
callback: (e) => centerHere(e, map),
},
"-", */ // Divider
"-", // Divider
],
});
@@ -746,7 +746,19 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//console.log("trigger in MapComponent.js:", poiReadTrigger);
}, [mapRef, map, poiReadTrigger, contextMenuItems]); // Prüfe die Abhängigkeiten sorgfältig
useEffect(() => {
/* const zoomIn = (e) => {
initMap.flyTo(e.latlng, 12);
//console.log("ZoomIn koordinaten in MapComponent", e.latlng);
};
const zoomOut = (e) => {
fly();
};
const centerHere = (e) => {
initMap.panTo(e.latlng);
}; */
/* useEffect(() => {
if (map) {
map.on("contextmenu", (e) => {
const contextMenuItems = [
@@ -783,7 +795,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
.openOn(map);
});
}
}, [map]);
}, [map]); */
// poiTyp Daten hinzufügen
//------------------------------------------
@@ -1707,14 +1719,14 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//------------------------------------------ */
// Effect to handle navigation to selected area
useEffect(() => {
/* useEffect(() => {
if (selectedArea && map) {
const marker = findMyMarker(selectedArea);
if (marker) {
map.flyTo(marker.getLatLng(), 14); // Adjust zoom level as needed
}
}
}, [selectedArea, map, allMarkers]); // Include allMarkers in the dependencies
}, [selectedArea, map, allMarkers]); // Include allMarkers in the dependencies */
//------------------------------------------
@@ -2146,6 +2158,36 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
}
}, [map]);
//------------------------------------------ */hier ist das Bug
// Effect to handle navigation to selected area
/* useEffect(() => {
if (selectedArea && map) {
const marker = findMyMarker(selectedArea);
if (marker) {
map.flyTo(marker.getLatLng(), 14); // Adjust zoom level as needed
}
}
}, [selectedArea, map, allMarkers]); // Include allMarkers in the dependencies */
//------------------------------------------
//--------------------------------------------------------- Kein Bug
useEffect(() => {
if (selectedArea && map) {
const station = GisStationsStaticDistrict.find(
(s) => s.Area_Name === selectedArea
);
if (station) {
map.flyTo([station.X, station.Y], 14);
}
}
}, [selectedArea, map, GisStationsStaticDistrict]);
useEffect(() => {
if (zoomTrigger && map) {
map.flyTo([51.41321407879154, 7.739617925303934], 7);
}
}, [zoomTrigger, map]);
//---------------------------------------------------------
//---------------------------------------------------------

View File

@@ -1,10 +1,9 @@
// utils/zoomAndCenterUtils.js
export const zoomIn = (e, map) => {
if (!map) {
console.error("map is not defined in zoomIn");
return;
}
map.flyTo(e.latlng, 12);
map.flyTo(e.latlng, map.getZoom() + 1);
localStorage.setItem("mapZoom", map.getZoom());
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
};
@@ -28,4 +27,6 @@ export const centerHere = (e, map) => {
return;
}
map.panTo(e.latlng);
localStorage.setItem("mapZoom", map.getZoom());
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
};