JustFly1984 / react-google-maps-api

React Google Maps API
MIT License
1.79k stars 438 forks source link

Autocomplete initial value #3297

Open mp3por opened 12 months ago

mp3por commented 12 months ago

How to set the autocomplete initial value.

UseCase - I use the autocomplete component when a user wants to select his address. Once I know his address he can always go back and change it. When he enters the "select user address" page I want to prepopulate the search with the users previous selection, however I can not do it.

Please help

mp3por commented 12 months ago

I found out how. Thank you.

nalnir commented 10 months ago

@mp3por How did you do it? I'm trying but can't figure it out

mp3por commented 9 months ago

@mp3por How did you do it? I'm trying but can't figure it out

`<FormField control={form.control} name='address' render={({ field }) => (

setAutocomplete(autocomplete)} options={{ componentRestrictions: { country: ['bg', 'ro'] }, fields: ['address_components', 'formatted_address', 'geometry', 'name', 'place_id'], }} onPlaceChanged={handleAutocompleteSelect} >
      )}
    />`

I use the placeholder attribute of the Input element.