diff --git a/components/CoordinateInput.js b/components/CoordinateInput.js new file mode 100644 index 000000000..27003bfec --- /dev/null +++ b/components/CoordinateInput.js @@ -0,0 +1,24 @@ +// components/CoordinateInput.js +import React, { useState } from "react"; + +const CoordinateInput = ({ onCoordinatesSubmit }) => { + const [coordinates, setCoordinates] = useState(""); + + const handleSubmit = (e) => { + e.preventDefault(); + if (onCoordinatesSubmit) { + onCoordinatesSubmit(coordinates); + } + }; + + return ( +
+ ); +}; + +export default CoordinateInput; diff --git a/components/MapComponent.js b/components/MapComponent.js index 8b08238e3..0a944eb63 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -62,6 +62,7 @@ import { polylineLayerVisibleState } from "../redux/slices/polylineLayerVisibleS //-------------------------------------------- import { useSelector, useDispatch } from "react-redux"; import { selectCurrentPoi, setCurrentPoi, clearCurrentPoi } from "../redux/slices/currentPoiSlice"; +import CoordinateInput from "./CoordinateInput"; const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const dispatch = useDispatch(); @@ -856,7 +857,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //--------------------------------------- useEffect(() => { if (map) { - initGeocoderFeature(map); // Geocoder-Feature initialisieren, kann von .env.local ausgeschaltet werden + // initGeocoderFeature(map); // Geocoder-Feature initialisieren, kann von .env.local ausgeschaltet werden } }, [map]); //-------------------------------------------- @@ -903,6 +904,13 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { fetchData(); }, [dispatch]); + //-------------------------------------------- + const handleCoordinatesSubmit = (coords) => { + const [lat, lng] = coords.split(",").map(Number); + if (map && lat && lng) { + map.flyTo([lat, lng], 12); // Zentriere die Karte auf die Koordinaten + } + }; //-------------------------------------------- return ( @@ -927,6 +935,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { {isDataLoaded &&