2017-01-30 166 views
1

I don't want have different countries search suggestions in my app(Image)显示在谷歌地图搜索附近的地方安卓

I want to have correct or nearest suggestions in google map app(Image)

我有这个代码

autocompleteFragment = (PlaceAutocompleteFragment) 
       getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment); 
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder() 
       .setTypeFilter(AutocompleteFilter.TYPE_FILTER_REGIONS) 
       .build(); 

autocompleteFragment.setFilter(typeFilter); 

我想告诉附近的地方,当我在搜索栏我打字测试。我的问题是,当一个字符在搜索栏中输入时,该字符与其他国家/地区相关的建议,我希望它是最接近的一个。换句话说,搜索是非常类似像Android谷歌地图应用程序。

+0

只有到附近的地方才需要网络服务API。这个API提供了最近的地方。它不是免费的,但是开发者可以使用这个API达到一些限制。 ** API是:** https://maps.googleapis.com/maps/api/place/nearbysearch/ ** Documentaion:** https://developers.google.com/places/web-服务/搜索 – Lokesh

回答

0

AutoCompleteSearch组件不显示附近的地方。我已经通过使用Google Map网络服务API实现了。

Web的API: maps.googleapis.com/maps/api/place/nearbysearch (GET)
参数:密钥(您的API密钥),
位置(经纬度+ “” +郎),
半径(5000),
传感器(真)
注意:我启用谷歌的地方API Web服务。

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

这是行不通的。我做了。感谢您的快速响应。 – Lokesh

+0

对于预测结果 有一个简单的解决方案。 Places.GeoDataApi .getAutocompletePredictions(mGoogleApiClient,constraint.toString(), mBounds,mPlaceFilter); 它绝对有效。 –

+0

你能分享代码吗?我在哪里放你的例子? – Lokesh