ErrorPro / react-google-autocomplete

React components for google places API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

usePlacesAutocompleteService requests with combination of type "establishment" with any other type from table 2 always fails

Hugh2425 opened this issue · comments

Hi not sure if this is an issue with your Library or the google docs, any guidance would be greatly appreciated.

On Google places autocomplete api docs it says that you can use types from 3 different tables to filter your place predictions

[Table 1] lists the types that are supported for place searches, and can be returned with Place details results, and as part of autocomplete place predictions.
[Table 2] lists additional types that can be returned with Place details results, and as part of autocomplete place predictions.
[Table 3]lists types you can use in place autocomplete requests.

it also states that
The request will be rejected if:

You specify more than five types.
You specify any unrecognized types.
You mix any types from [Table 1] or [Table 2] with any filter from [Table 3]

however the type "establishment" exists in both table 2 and 3. this causes an issue when we try to do the following

const {
    placesService,
    placePredictions,
    getPlacePredictions
  } = usePlacesAutocompleteService({
    apiKey: googleAutoCompleteApiKey,
    options: { componentRestrictions: { country: ["gb", "im"] }, types: ["premise", "establishment"] }
  });

as it thinks I'm trying to combine table 2 and table 3 filters but really I'm trying to just use the types from table 2.

docs I have used
https://developers.google.com/maps/documentation/places/web-service/supported_types
https://developers.google.com/maps/documentation/javascript/place-autocomplete