简体   繁体   English

如何通过特定区域类型(国家/地区,子网站等)在Google Places API for Android中获取搜索自动填充功能?

[英]How to get search autocomplete in Google Places API for Android only by specific region type (country, sublocality etc.)?

I'm trying to create autocomplete searching in my Android app via Google Places API for Android. 我正在尝试通过适用于Android的Google Places API在我的Android应用中创建自动完成搜索。 Main goal is to search only by cities and administrative_area_level_1 , but unfortunately I can't find way to create such AutocompleteFilter . 主要目标是仅按城市administrative_area_level_1进行搜索,但遗憾的是我找不到创建此类AutocompleteFilter的方法 Maybe someone had the same problem? 也许有人有同样的问题?

I'm using Play Services ver. 我正在使用Play Services ver。 9.8.0 9.8.0

 StringBuilder sb = new StringBuilder(PLACES_API_BASE + TYPE_AUTOCOMPLETE + OUT_JSON);
        sb.append("?key=" + API_KEY);
        sb.append("&components=country:IN");
        sb.append("&input=" + URLEncoder.encode(input, "utf8"));

There isn't a single filter that does exactly what you want, unfortunately. 遗憾的是,没有一个过滤器完全符合您的要求。 AutocompleteFilter allows you to specify TYPE_FILTER_REGIONS or TYPE_FILTER_CITIES but these can't be combined in a single filter. AutocompleteFilter允许您指定TYPE_FILTER_REGIONSTYPE_FILTER_CITIES但这些不能在单个过滤器中组合。 Also, TYPE_FILTER_REGIONS can return things other than administrative_area_level_1 . 此外, TYPE_FILTER_REGIONS可以返回除administrative_area_level_1之外的其他内容。

One solution might be to make two autocomplete request in parallel with the two different filter settings and combine the results. 一种解决方案可能是与两个不同的过滤器设置并行地生成两个自动完成请求并组合结果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Google Places Android API 中将自动完成搜索限制为特定国家/地区 - Restrict Autocomplete search to a particular country in Google Places Android API 如何在Google Places API中针对Android中的自动完成预测获取特定国家/地区的结果? - How to get Country Specific Results in Google Places API for AutocompletePredictions in Android? 如何限制谷歌地方自动填充到特定国家/地区? - how to restrict google places autocomplete to specific country? Android:如何使用Google Places API(自动填充)搜索附近的酒店? - Android: How to search for nearby hotels using the Google Places API (Autocomplete)? 将地方自动填充API限制为特定国家/地区Android的城市 - Restrict Places Autocomplete API to cities of specific country android 如何仅从PlaceAutocomplete android获取特定国家/地区的搜索结果? - How to get search result of a Specific country only from PlaceAutocomplete android? 如何获取Autocomplete TextView Google Places API? - How to get Autocomplete textview google places api? 从 PlaceAutocompleteFragment android (Google Places API) 获取国家代码 - Get country code from PlaceAutocompleteFragment android (Google Places API) 从PlaceAutocomplete android获取国家代码(Google Places API) - Get country code from PlaceAutocomplete android (Google Places API) Google Places API 自动完成仅获取城市列表 - Google Places API Autocomplete get cities List only
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM