From f152476d8fa297730211b42371728bf965c130ba Mon Sep 17 00:00:00 2001 From: toqvist Date: Wed, 21 Feb 2024 16:36:39 +0100 Subject: [PATCH] Set lon/lat on data fetch --- src/customFields/geoPicker/GeoPicker.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/customFields/geoPicker/GeoPicker.tsx b/src/customFields/geoPicker/GeoPicker.tsx index 64cf359..db5a2a9 100644 --- a/src/customFields/geoPicker/GeoPicker.tsx +++ b/src/customFields/geoPicker/GeoPicker.tsx @@ -1,15 +1,13 @@ import * as React from 'react'; -import { useField, Label, TextInput } from 'payload/components/forms'; +import { useField } from 'payload/components/forms'; export const GeoPicker: React.FC<{ path: string }> = ({ path }) => { const { value, setValue } = useField({ path }); - const [latitude, setLatitude] = React.useState(""); - const [longitude, setLongitude] = React.useState(""); + const [longitude, setLongitude] = React.useState(value[0]); + const [latitude, setLatitude] = React.useState(value[1]); const handleCityEnter = async (e) => { - console.log("Handle key") if (e.key === 'Enter') { - console.log("Enter: " + e.target.value) try { const response = await fetch( `https://nominatim.openstreetmap.org/search?format=json&q=${e.target.value}` @@ -20,7 +18,6 @@ export const GeoPicker: React.FC<{ path: string }> = ({ path }) => { setLatitude(lat); setLongitude(lon); setValue([lon, lat]); - console.log(data) } } catch (error) { console.error('Error fetching geolocation:', error);