我在我的应用中使用谷歌地图,并希望在其中使用搜索,但问题是我想获得一个特殊区域的结果或只是在城市搜索!
这是我的代码:
final int PLACE_AUTOCOMPLETE_REQUEST_CODE = 1;
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setCountry("IR")
.build();
try {
Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.setBoundsBias(new LatLngBounds(new LatLng(38.051183, 46.211586),
new LatLng(38.132784, 46.392860)))
.setFilter(typeFilter)
.build(MainActivity.this);
startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
} catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
e.fillInStackTrace();
}