使用 Google 地点自动完成功能限制国家/地区的结果?

Limiting result in country with Google Place autocomplete?

我刚试过 this demo,但我找不到如何在国家/地区限制结果。 我也在 com.google.android.gms.location.places.GeoDataApi 中检查了 getAutocompletePredictions,但我找不到任何文档来实现限制国家。

我也在SO里面搜索了一些问题;显然是 JavaScript,需要添加一些 "optional param"。那么如何在这个请求中添加可选参数呢?

https://developers.google.com/places/webservice/search

  1. 您可以在查询中添加国家名称,例如"in australia"以限制在澳大利亚的搜索

2。添加半径参数以限制搜索

应该是这样,但是不行,因为google play service library v7?

List<Integer> autocompleteFilter = new ArrayList<Integer>();
autocompleteFilter.add(Place.TYPE_COUNTRY);

// Set up the adapter that will retrieve suggestions from the Places Geo Data API that cover
// the entire world.
mAdapter = new PlaceAutocompleteAdapter(this, android.R.layout.simple_list_item_1,
BOUNDS_JAKARTA, AutocompleteFilter.create(autocompleteFilter));