react-google-maps-api icon indicating copy to clipboard operation
react-google-maps-api copied to clipboard

Using Autocomplete Outside of a Map?

Open pihish opened this issue 2 years ago • 1 comments

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.

pihish avatar Mar 23 '22 17:03 pihish

I used useJsApiLoader hook in HOC and the Autocomplete can separate in different file.

Malaaaa avatar Jun 05 '22 02:06 Malaaaa

Hello @pihish , You can go through my project. I had implemented what you are looking for.

https://github.com/tj-webdev/cab-fare-predictor

tj-webdev avatar Sep 22 '22 18:09 tj-webdev