我正在Android中实施Google地方信息自动填充API。它应该只显示15公里半径LatLong 10.0158605,76.3418666
中的位置。问题是,它还将显示印度的其他地方以及这个15公里范围内的地方。有没有办法到Strictly Bound只有15公里的地方?我发现Javascript中的代码给出了限制并严格限制。但我不知道如何在Android中解决它。请给出一个解决方案。
/* autocomplete.setComponentRestrictions(
{'location': '10.0158605,76.3418666',
'radius':15});
autocomplete.setOptions({strictBounds: true}); */ //JavaScript
private static final LatLng south=new LatLng(9.876752,76.483111);
private static final LatLng north=new LatLng(10.141144,76.470065);
private static final LatLngBounds BOUNDS_MOUNTAIN_VIEW1=LatLngBounds.builder().include(north).include(south).build();
location.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_REGIONS)
.setCountry("IN")
.build();
try {
Intent intent = new PlaceAutocomplete.IntentBuilder
(PlaceAutocomplete.MODE_OVERLAY)
.setBoundsBias(BOUNDS_MOUNTAIN_VIEW1)
.setFilter(typeFilter)
.build(getActivity());
startActivityForResult(intent, REQUEST_SELECT_PLACE);
} catch (GooglePlayServicesRepairableException |
GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
});