I want to be able to autocomplete some places by using the google places api. I only want to include certain places from a certain area. Googles API docs describe this feature by using the function setBoundsBias
, but I can't seem to get it working properly as it still returns results from outside the specified area.
try {
Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.setBoundsBias(new LatLngBounds(
new LatLng(16.371163, 21.051073),
new LatLng(16.725743, 21.424006)))
.build(getActivity());
startActivityForResult(intent, requestCode);
} catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
The setBoundsBias
is supposed to return results from outside the area. It is only a bias. If you want to exclusively return results from within the bounds, you must use the AutocompleteFilter
. Unfortunately currently the only level of filtering by region is by country.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.