import { Combobox } from '@headlessui/react'; import { MagnifyingGlassIcon, XMarkIcon } from '@heroicons/react/24/outline'; import React, { useState } from 'react'; import PlacesAutocomplete, { geocodeByAddress, getLatLng, } from 'react-places-autocomplete'; import { Location } from '../Location/Location'; export const LocationPicker = () => { const [address, setAddress] = useState(''); const [coordinates, setCoordinates] = useState({ lat: 0, lng: 0, }); const handleSelect = async (value: any) => { const results = await geocodeByAddress(value); const latLng = await getLatLng(results[0]); setAddress(value); setCoordinates(latLng); }; return (
{({ getInputProps, suggestions, getSuggestionItemProps }) => (
{suggestions.map(suggestion => { return ( {({ active }) => (
  • {suggestion.description}
  • )}
    ); })}
    )}
    ); };