google-maps-services-java icon indicating copy to clipboard operation
google-maps-services-java copied to clipboard

Places: PlaceAutocompleteType is missing values

Open michael-ameri opened this issue 3 years ago • 4 comments

Environment details

Library version: 2.1.2

Code example

PlacesApi.placeAutocomplete(someContext, "Zurich", new PlaceAutocompleteRequest.SessionToken())
            .types(PlaceAutocompleteType.ESTABLISHMENT)

2 issues:

  1. The PlaceAutocompleteType enum only covers a small subset of available types according to https://developers.google.com/maps/documentation/places/web-service/supported_types#table2
  2. There is no way to use multiple types, which is possible via REST calls.

michael-ameri avatar Nov 23 '22 09:11 michael-ameri

  1. The PlaceAutocompleteType enum only covers a small subset of available types according to https://developers.google.com/maps/documentation/places/web-service/supported_types#table2

Found workaround with .custom method:

PlacesApi.placeAutocomplete(someContext, "Zurich", new PlaceAutocompleteRequest.SessionToken())
            .custom("types", "route")
  1. There is no way to use multiple types, which is possible via REST calls.

You can chain calls to have multiple types:

PlacesApi.placeAutocomplete(someContext, "Zurich", new PlaceAutocompleteRequest.SessionToken())
            .types(PlaceAutocompleteType.ESTABLISHMENT)
            .types(PlaceAutocompleteType.ADDRESS)  

n10v avatar Aug 14 '23 19:08 n10v

Actually I just tried to chain calls and the last value overwrites the first one :(

n10v avatar Aug 15 '23 08:08 n10v

  1. In an Autocomplete request, it is possible to filter by at most one element of the types contained in the enum PlaceAutocompleteType. This is correct https://developers.google.com/maps/documentation/places/web-service/autocomplete?hl=it#types

  2. What should be added is the possibility to filter an autocomplete request with multiple types that are not part of the enum PlaceAutocompleteType.

For example, we could introduce on PlaceAutoCompleteRequest:

 /**
   * Restricts the results to places matching the specified types
   *
   * @param types The {@link PlaceType}s to restrict results to.
   * @return Returns this {@code PlaceAutocompleteRequest} for call chaining.
   */
  public PlaceAutocompleteRequest types(PlaceType... types) {
    return param("types", join('|',  types));
  }

What do you think @n10v ?

marcoserafini2 avatar Jul 23 '24 10:07 marcoserafini2

  1. The link is leading to the following URL, which shows 0 issues for me (probably the issues are private): https://github.com/googlemaps/google-maps-services-java/issues/url
  2. Makes sense!

n10v avatar Jul 23 '24 14:07 n10v

I'm sorry @n10v , I sent the wrong link. I just corrected it. I will try to send a pull request asap

marcoserafini2 avatar Jul 23 '24 14:07 marcoserafini2