ErrorPro / react-google-autocomplete

React components for google places API.
MIT License
462 stars 114 forks source link

Autocomplete is only giving me cities and locations, not addresses #209

Closed abdu997 closed 1 year ago

abdu997 commented 1 year ago

Hello, I'm trying to use this package for my address autocomplete field, but it's not giving me any results when I start typing an address.

What do I do?

<ReactGoogleAutocomplete
                                                    apiKey={
                                                        process.env
                                                            .NEXT_PUBLIC_GOOGLE_MAPS_API_KEY
                                                    }
                                                    onPlaceSelected={(
                                                        place
                                                    ) => {
                                                        console.log(place);
                                                    }}
                                                />
abdu997 commented 1 year ago

Nevermind, I needed to add field types

options={{
                                                        types: ["address"],
                                                        componentRestrictions: { country: "us" },
                                                      }}
<Autocomplete
                                                    apiKey={
                                                        process.env
                                                            .NEXT_PUBLIC_GOOGLE_MAPS_API_KEY
                                                    }
                                                    options={{
                                                        types: ["address"],
                                                        componentRestrictions: { country: "us" },
                                                      }}
                                                    onPlaceSelected={(
                                                        place
                                                    ) => {
                                                        console.log(place);
                                                    }}
                                                />
code-creativeapps commented 1 year ago

Althought this is a more of a google api configuration, it would be helpful to have it clearly stated in this library's documentation, because that's 99% of the use cases :) (And it takes a while to figure out with how dense the google documentation is)