Restrict Autocomplete search to a particular country in Google Places Android API

后端 未结 5 1733
野的像风
野的像风 2020-12-15 17:44

My goal is to restrict the Autocomplete results from the Google Places Android API to a particular country (United States) only.

I am using the following API:

5条回答
  •  臣服心动
    2020-12-15 18:15

    For new Place api 2019, You have to do this

        FindAutocompletePredictionsRequest request = 
        FindAutocompletePredictionsRequest.builder()
       .setLocationBias(bounds)
       .setCountry("au")   //to set country only for e.g australia
       .setTypeFilter(TypeFilter.ADDRESS) 
       .setSessionToken(token)
       .setQuery(query)
       .build();
    

提交回复
热议问题