1

I'm facing a similar problem like this post Google Maps Autocomplete WITHOUT Atmosphere Data but I'm just looking for a solution that could be applied in reactjs.

I'm already using this wrapper https://tomchentw.github.io/react-google-maps

But I cannot find where to put the AutocompleteOptions.

evan
  • 5,443
  • 2
  • 11
  • 20
Erick Vivanco
  • 239
  • 4
  • 10
  • 1
    This library hasn't exposed the Autocomplete Feature. You have 3 options : 1. use a different library/direct JS. 2. Ask this library owner to add that feature/expose api. 3 you write it yourself and submit PR – Shivam Gupta Aug 15 '19 at 16:38

1 Answers1

1

The react-google-maps library does not include the Place Autocomplete service; it only offers SearchBox which doesn't allow you to specify fields. However I've done a quick search and have found the following reactjs libraries (and I'm sure there are a few more out there):

  1. react-google-autocomplete which states the following in its readme:

    You can also set fields prop if you need extra information, now it defaults to basic data in order to control expenses.

  2. react-places-autocomplete which doesn't currently support fields as per this issue.

  3. react-google-places-autocomplete which based on the documentation doesn't appear to support specifying fields either.

Note that you can always file a FR or submit a PR yourself.

My approach: take a look at this codesandbox to see an Autocomplete input in action using #1 that only requests Basic Data fields. Add your own API key to the Google Maps JS API script in index.html to run it.

Hope this helps!

evan
  • 5,443
  • 2
  • 11
  • 20