Reputation: 197
Is it possible to locate the pin on the map when searching for a place in the google places Activity? Now, when I am searching a place in my app, I start the places Activity, there is a map and I am searching for a place. The place is found and a marker is added to the place, but the camera stays at my location...
Here's the code where I am starting the google places activity:
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
try {
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
And here's my OnActivityResult code:
public void action(Context context, Intent data, final TextView addressText, GoogleApiClient googleApiClient){
Place place = PlacePicker.getPlace(context, data);
if(addressText!=null) {
Places.GeoDataApi.getPlaceById(googleApiClient, place.getId()).setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
//Work with the data
places.release();
}
});
/*Show the address in to the text view with animation*/
addressText.setAnimation(AnimationUtils.loadAnimation(context, R.anim.address_text_anim));
}
}
Upvotes: 0
Views: 324
Reputation: 371
You can try something like this:
LatLng newLatLng = new LatLng(location.getLatitude(), location.getLongitude());
CameraUpdate cu = CameraUpdateFactory.newLatLngZoom(newLatLng , yourdesiredvalue);
map.animateCamera(cu);
Upvotes: 0
Reputation: 109
Use animate camera method.
LatLng latLng = new LatLng(22.3075, 72.12345);
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 10);
map.animateCamera(cameraUpdate);
Upvotes: 3