将谷歌预测限制在特定国家/地区不起作用
Posted
技术标签:
【中文标题】将谷歌预测限制在特定国家/地区不起作用【英文标题】:Limiting google prediction to a specific country doesn't work 【发布时间】:2020-05-16 20:41:35 【问题描述】:我正在做以下事情:
FindAutocompletePredictionsRequest.Builder requestBuilder = FindAutocompletePredictionsRequest.builder();
if (limitToCountry != null)
requestBuilder.setCountry(limitToCountry.toLowerCase());
requestBuilder.setSessionToken(HPlaces.getAutocompleteSessionToken());
requestBuilder.setTypeFilter(TypeFilter.ADDRESS);
try
mAutoCompleteAdapter = new PlacesAutoCompleteAdapter(
this,
R.layout.item_select_address,
latLngBounds.build(),
requestBuilder
);
catch (IllegalStateException e)
//Issue with latLngBounds.build() not having included points in it
finish();
return;
问题是,如果限制国家是“ro”(罗马尼亚),如果我查询谷歌,它也会返回来自其他国家的结果。为什么会这样?!
【问题讨论】:
【参考方案1】:试试这个
AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder()
.setTypeFilter(Place.TYPE_COUNTRY)
.setCountry("US")
.build();
Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
.setFilter(autocompleteFilter)
.build(this);
【讨论】:
AutocompleteFilter以上是关于将谷歌预测限制在特定国家/地区不起作用的主要内容,如果未能解决你的问题,请参考以下文章
绑定到 ViewModel 在 Xamarin.Forms 中不起作用