react-google-maps-api
react-google-maps-api copied to clipboard
Using Autocomplete Outside of a Map?
Is there a way to use Autocomplete without wrapping a GoogleMap component around it? I'd like to use it for populating an address form and out of the context of a drawn Google Map.
I have the following right now:
<LoadScript googleMapsApiKey="mysecretekey" libraries={['places']}>
<Autocomplete
onLoad={(param) => console.log('asdf')}
onPlaceChanged={() => console.log('dfaf')}
>
<input type="text"/>
</Autocomplete>
</LoadScript>
The above returns an Unhandled Rejection (InvalidValueError): not a LatLngBounds or LatLngBoundsLiteral: unknown property wb
error. Looking at the stack trace, I can tell that it's trying to set bounds on a non-existent instance of Google Maps.
I used useJsApiLoader hook in HOC and the Autocomplete can separate in different file.
Hello @pihish , You can go through my project. I had implemented what you are looking for.
https://github.com/tj-webdev/cab-fare-predictor