feat: Marker hinzufügen und Marker entfernen in PolyLines und der currentZoom funktioniert
This commit is contained in:
@@ -81,7 +81,11 @@ import useMapContextMenu from "./useMapContextMenu.js";
|
||||
//---------------------------------------------------------------------
|
||||
//-------------------- MapComponent -----------------------------------
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const [currentZoom, setCurrentZoom] = useState(12);
|
||||
const [currentZoom, setCurrentZoom] = useState(() => {
|
||||
const storedZoom = localStorage.getItem("mapZoom");
|
||||
return storedZoom ? parseInt(storedZoom, 10) : 12;
|
||||
});
|
||||
|
||||
const [currentCenter, setCurrentCenter] = useState(() => {
|
||||
const storedCenter = localStorage.getItem("mapCenter");
|
||||
try {
|
||||
@@ -242,10 +246,15 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const zoomIn = (e) => {
|
||||
initMap.flyTo(e.latlng, 12);
|
||||
//console.log("ZoomIn koordinaten in MapComponent", e.latlng);
|
||||
// Speichern der Daten in LocalStorage
|
||||
localStorage.setItem("mapZoom", map.getZoom());
|
||||
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
|
||||
};
|
||||
|
||||
const zoomOut = (e) => {
|
||||
fly();
|
||||
localStorage.setItem("mapZoom", map.getZoom());
|
||||
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
|
||||
};
|
||||
const centerHere = (e) => {
|
||||
initMap.panTo(e.latlng);
|
||||
@@ -2072,8 +2081,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
insertNewMarker(closestPoints, newPoint, lineData, map);
|
||||
redrawPolyline(lineData);
|
||||
//Browser aktualisieren
|
||||
localStorage.setItem("mapZoom", currentZoom);
|
||||
localStorage.setItem("mapCenter", JSON.stringify(currentCenter));
|
||||
//localStorage.setItem("mapZoom", currentZoom);
|
||||
//localStorage.setItem("mapCenter", JSON.stringify(currentCenter));
|
||||
window.location.reload();
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user