Reputation: 59
It works fine previously. I mean the code has not been changed since several months ago. This is what happen now, after I click an address from the autocomplete.
This is how I call the auto complete and the maps after pick a location.
private void openPlaceAutoComplete(){
try {
long touchTime = System.currentTimeMillis();
if(touchTime - latestTouchedTime > BOUNCE_DELAY){
latestTouchedTime = touchTime;
Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.build(this.getActivity());
startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST);
}
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
Then, on ActivityResult
else if(requestCode == PLACE_AUTOCOMPLETE_REQUEST){
if(resultCode == Activity.RESULT_OK){
Place place = PlaceAutocomplete.getPlace(this.getFragmentBaseContext(), data);
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
builder.setLatLngBounds(LocationHelper.getBoundsFromCenter(place.getLatLng(), PLACE_BOUND_RADIUS));
try{
startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST);
}catch (GooglePlayServicesNotAvailableException ex){
ex.printStackTrace();
}catch (GooglePlayServicesRepairableException ex){
ex.printStackTrace();
}
}
}
I have make sure the place is not null, and it has LatLng object which is not 0,0 and GetBoundsFromCenter function is simply like this.
public static LatLngBounds getBoundsFromCenter(LatLng center, double radius){
LatLng southwest = SphericalUtil.computeOffset(center, radius * Math.sqrt(2.0), 225);
LatLng northeast = SphericalUtil.computeOffset(center, radius * Math.sqrt(2.0), 45);
return new LatLngBounds(southwest, northeast);
}
Upvotes: 1
Views: 593
Reputation: 10889
Unfortunately, this is a bug in the current release of the Place Picker. See https://stackoverflow.com/a/37318013/2994 for more info.
Upvotes: 2