diff --git a/components/MapComponent.js b/components/MapComponent.js index 70ed0b610..6b72df435 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -79,6 +79,7 @@ import { MAP_VERSION } from "../config/settings"; import * as layers from "../config/layers.js"; import useMapContextMenu from "./useMapContextMenu.js"; import { openInSameWindow } from "../utils/openInSameWindow"; +import { zoomIn, zoomOut } from "../utils/zoomUtils"; //--------------------------------------------------------------------- //-------------------- MapComponent ----------------------------------- const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { @@ -234,20 +235,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //---------------------------------------------------- //-----Kontextmenu---------------- - - 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); }; diff --git a/package-lock.json b/package-lock.json index 92fbc2eda..6c27e183d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "nodeMap 11.07.2024", + "name": "nodeMap 12.07.2024", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/utils/zoomUtils.js b/utils/zoomUtils.js new file mode 100644 index 000000000..960f0835c --- /dev/null +++ b/utils/zoomUtils.js @@ -0,0 +1,15 @@ +// utils/zoomUtils.js +export const zoomIn = (e, map) => { + map.flyTo(e.latlng, 12); + localStorage.setItem("mapZoom", map.getZoom()); + localStorage.setItem("mapCenter", JSON.stringify(map.getCenter())); +}; + +export const zoomOut = (map) => { + const x = 51.41321407879154; + const y = 7.739617925303934; + const zoom = 7; + map.flyTo([x, y], zoom); + localStorage.setItem("mapZoom", map.getZoom()); + localStorage.setItem("mapCenter", JSON.stringify(map.getCenter())); +};