2015-04-19 51 views
5

我剛試過this demo,但是我找不到如何限制國家的結果。 我也檢查了com.google.android.gms.location.places.GeoDataApi中的getAutocompletePredictions,但是我找不到任何文件來實現限制國家。限制Google Place自動填充的國家/地區的結果?

我也在SO中搜索了一些問題;顯然它是JavaScript並需要添加一些「可選參數」。那麼如何在這個請求中添加可選的參數?

回答

2

https://developers.google.com/places/webservice/search

  1. 您可以在查詢中添加國家名稱,如 「澳大利亞」,以限制搜索在澳大利亞

2。添加一個半徑參數來限制搜索

+0

你能告訴我關於添加半徑參數嗎? (注:我在Android的地方api工作)。 THanks – quangson91

+0

我相信沒有sdk谷歌地圖地方搜索既不ios也不是android。 如果你是在一些框架的工作,我不禁 但如果你試圖通過自己 https://maps.googleapis.com/maps/api/place/radarsearch/json的API工作? location = 51.503186,-0.126446&radius = 5000&types = museum&key = AddYourOwnKeyHere – chings228

+0

您是否檢查:https://github.com/googlesamples/android-play-places/tree/master/PlaceComplete 當前我使用您的建議:添加「in +國家「 - >它工作:) 但我想知道如何在方法中實現」參數「:com.google.android.gms.location.places.GeoDataApi#getAutocompletePredictions – quangson91

0

應該是這樣的,但它不起作用,由於谷歌播放服務庫v7中的錯誤?

List<Integer> autocompleteFilter = new ArrayList<Integer>(); 
autocompleteFilter.add(Place.TYPE_COUNTRY); 

// Set up the adapter that will retrieve suggestions from the Places Geo Data API that cover 
// the entire world. 
mAdapter = new PlaceAutocompleteAdapter(this, android.R.layout.simple_list_item_1, 
BOUNDS_JAKARTA, AutocompleteFilter.create(autocompleteFilter)); 
+0

謝謝。但是,你怎麼看待「界限」:|,我認爲界限不能糾正,因爲沒有任何國家有sqr是矩形。 :| – quangson91

相關問題