【问题标题】:How to get search result of a Specific country only from PlaceAutocomplete android?如何仅从 PlaceAutocomplete android 获取特定国家的搜索结果?
【发布时间】:2016-09-20 08:01:04
【问题描述】:

我想要这个问题的解决方案,请建议该怎么做,我只想要来自谷歌的PlaceAutocomplete 的特定国家/地区的搜索结果,我如何设置过滤器以便它只显示该国家/地区的结果,例如如果我想要搜索结果(如果仅适用于印度)怎么做? PlaceAutocomplete 可以吗?

代码:

try {
        Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY).build(activity);
        startActivityForResult(intent, 1);
    } catch (GooglePlayServicesRepairableException e) {
        e.printStackTrace();
    } catch (GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }

如屏幕截图所示,它显示了世界范围内的结果,我只想要一个特定的国家

【问题讨论】:

标签: android google-places-api


【解决方案1】:

您可以使用 LatLngBounds 构造方法。这将帮助您限制对矩形区域的搜索(但这不一定会限制搜索一个国家,而是该矩形区域中的所有国家)。或者您可以使用 Google Places Web Service API,如 here

更多解释请参考这个答案here

【讨论】:

    【解决方案2】:

    对于当前城市的搜索地点,您必须将 LatLongBounds 设置为 PLaceAutocomplete 之类的。在这里查看我的答案Google Places API not returning suggestions based on location

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-02
      • 2014-03-10
      • 1970-01-01
      • 2013-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多