【问题标题】:How to Use google places api in android with restrict particular place?如何在限制特定位置的情况下在 android 中使用 google places api?
【发布时间】:2016-02-12 05:56:19
【问题描述】:

嘿,伙计们,我基本上想创建一个具有自动完成文本视图并根据用户搜索显示位置的应用程序,我只是限制用户仅显示印度的城市名称而不是其他城市名称。 任何人都可以知道吗?

【问题讨论】:

标签: android google-maps google-api google-places-api android-googleapiclient


【解决方案1】:

要搜索仅限于 India 的地方,您可以在代码中使用 setBoundsBias()。Google 现在提供了自动完成小部件,这让事情变得更加简单。 请看这个链接: https://developers.google.com/places/android-api/autocomplete

【讨论】:

    【解决方案2】:

    创建一个过滤器并在过滤器中设置国家为印度,并在 PlaceAutoComplete 片段或意图中设置过滤器。

    AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
        .setCountry("IN")
        .build();
    autocompleteFragment.setFilter(typeFilter);
    

    【讨论】:

      【解决方案3】:

      这对我有用

      try {
                      AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
                              .setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
                              .setCountry("au")
                              .build();
                      Intent intent = new PlaceAutocomplete.IntentBuilder
                              (PlaceAutocomplete.MODE_FULLSCREEN)
                              .setFilter(typeFilter)                         
                              .build(ProfileActivity.this);
                      startActivityForResult(intent, REQUEST_SELECT_PLACE);
                  } catch (GooglePlayServicesRepairableException |
                          GooglePlayServicesNotAvailableException e) {
                      e.printStackTrace();
                  }
      

      【讨论】:

        猜你喜欢
        • 2013-01-21
        • 2015-03-18
        • 2013-04-03
        • 2016-06-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-05
        相关资源
        最近更新 更多