Autocomplete component wraps an input element and provides place autocomplete suggestions from the Google Places API.
Import
Requires the Places library. Pass
libraries={['places']} to LoadScript or useJsApiLoader.Usage
Props
A single child element, typically an
<input> element, that will receive autocomplete functionality.Options for configuring the autocomplete behavior.
The bounds within which to bias the autocomplete predictions. Predictions will be biased towards, but not restricted to, the specified bounds.
Restricts predictions to specific countries. For example:
{ country: 'us' } or { country: ['us', 'ca'] }.The fields to be included in the place result. This can reduce billing costs by requesting only the data you need. Example:
['name', 'geometry', 'formatted_address'].The types of predictions to return. For example:
['geocode'], ['address'], or ['establishment'].CSS class name to apply to the wrapper div.
Callback fired when the user selects a place from the autocomplete suggestions. Use the autocomplete instance (from
onLoad) to get the selected place.Callback invoked when the autocomplete instance has been created.Parameters:
autocomplete: The autocomplete instance. Use this to call methods likegetPlace().
Callback invoked when the component unmounts.Parameters:
autocomplete: The autocomplete instance