GVillani82
GVillani82

Reputation: 17429

Set both bounds and tilt in google maps v2

I need to set at the same time tilt and bounds to th camera in my map.

So I think I need this:

mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));

but I don't know how can I add also tilt.

If I try to insert other code, like this:

mMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder()
                            .target(mMap.getCameraPosition().target)
                            .zoom(mMap.getCameraPosition().zoom)
                            .bearing(30)
                            .tilt(45)
                            .build()));

only the second animation is done. So, the tilt is applied, but I have not the correct bounds.

So, the question, as said in the question's title: how can I set both tilt and bounds for my camera?

Upvotes: 1

Views: 1572

Answers (1)

Chris Feist
Chris Feist

Reputation: 1676

Why don't you wait for the first animation with the bounds to complete, then animate the tilt when it finishes?

mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50), 
        new CancelableCallback() {
                    @Override
                    public void onFinish() {
                        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder(mMap.getCameraPosition())
                                .bearing(30)
                                .tilt(45)
                                .build()));
                    }

                    @Override
                    public void onCancel() {
                    }
                });

Upvotes: 5

Related Questions