android - 如何使用 Android Places API AutocompleteFilter

标签 android google-maps autocomplete google-places-api

我正在尝试在我的应用程序中实现适用于 android 的新 Places API,但我似乎无法弄清楚如何为请求设置过滤器。这是我的代码。

LatLng southWest = new LatLng(85, -180);
LatLng northEast = new LatLng(-85, 180);
LatLngBounds bounds = new LatLngBounds(southWest, northEast);
AutocompleteFilter filter = AutocompleteFilter.create(WHAT SHOULD GO HERE?);
PendingResult result = Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient,
            search.getText().toString(), bounds, filter);

如您所见,我遵循了 google here 提供的文档但是我在阅读 API Reference 之后,他们并没有谈论如何实现过滤器。我仍然不知道如何实现 API。

我需要帮助确定 API 的 AutocompleteFilter.create() 参数应该包含哪些内容。我想按城市过滤数据

谢谢

最佳答案

它适用于 Google Play 服务 9.4。

AutocompleteFilter filter = new AutocompleteFilter.Builder()
        .setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
        .build();

关于android - 如何使用 Android Places API AutocompleteFilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29978325/

相关文章:

java - 用垂直线和水平线/ View 划分屏幕

java - onClick 找不到它的方法

javascript - 谷歌地图 : get route, 公里,和...价格

visual-studio - 在 Visual Studio 中键入属性值时,如何将光标移过结束引号?

vim - 如何禁用vim内置关键字自动完成功能?

android - 将 Android App Bundle 上传到 Google Play 控制台 - key 签名错误

android - com.google.android.maps 包不存在

android - 在 google play 中更新了带有 v1 map 的应用程序,现在显示空白图 block

google-maps - 标记管理器不显示标记

c# - ComboBox - 自动完成 + 自由打字