diff --git a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx
index fc2a56ba..e2872223 100644
--- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx
+++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx
@@ -72,7 +72,7 @@ export const SearchControl = ({ clusterRef }) => {
{value.length > 0 && }
- {hideSuggestions || Array.from(geoResults).length == 0 && itemsResults.length == 0 && tagsResults.length == 0 || value.length == 0 ? "" :
+ {hideSuggestions || Array.from(geoResults).length == 0 && itemsResults.length == 0 && tagsResults.length == 0 && !isGeoCoordinate(value)|| value.length == 0? "" :
{tagsResults.length > 0 &&
@@ -130,6 +130,21 @@ export const SearchControl = ({ clusterRef }) => {
))}
+ {isGeoCoordinate(value) &&
+
+
+
+
{
+ map.setView(new LatLng(extractCoordinates(value)![0], extractCoordinates(value)![1]), 15, { duration: 1 })
+ }}>
+
{value}
+
{"Coordiante"}
+
+
+ }
}
}
@@ -138,6 +153,32 @@ export const SearchControl = ({ clusterRef }) => {
)
}
+function isGeoCoordinate(input) {
+ console.log(input);
+
+ const geokoordinatenRegex = /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/;
+
+ return geokoordinatenRegex.test(input);
+
+}
+
+function extractCoordinates(input): number[] | null {
+ const result = input.split(",")
+
+
+
+ if (result) {
+ const latitude = parseFloat(result[0]);
+ const longitude = parseFloat(result[1]);
+ console.log([latitude, longitude])
+
+ if (!isNaN(latitude) && !isNaN(longitude)) {
+ return [latitude, longitude];
+ }
+ }
+
+ return null; // Invalid input or error
+}
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);