[英]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_REGIONS
或TYPE_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.