user1531170
user1531170

Reputation: 63

How to move camera to max zoom Level on Map In Android

map.setOnMarkerClickListener(new OnMarkerClickListener() {

                @Override
                public boolean onMarkerClick(Marker arg0) {
                    // TODO Auto-generated method stub

                    LatLng point = arg0.getPosition();
                    CameraPosition cameraPosition = new CameraPosition.Builder()
                            .target(point)
                            .tilt(90).zoom(map.getCameraPosition().zoom)
                            .build();

                    map.animateCamera(CameraUpdateFactory
                            .newCameraPosition(cameraPosition), 
                            new CancelableCallback() {

                                @Override
                                public void onFinish() {
                                    // TODO Auto-generated method stub
                                     Toast.makeText(getActivity(), "finsih",
                                     10000).show();

                                }

                                @Override
                                public void onCancel() {
                                    // TODO Auto-generated method stub
                                     Toast.makeText(getActivity(), "cancel",
                                     10000).show();

                                }
                            });

                    return false;

                }
            });

This is my code. I am displaying a marker on Google maps, I want that when I click on the marker the camera should move to max zoom level at street.

How can I achieve this? How should I write the code for the oncancel and onfinish methods?

Upvotes: 2

Views: 1376

Answers (1)

Vui Dang
Vui Dang

Reputation: 158

You can try it , it work for me . . ., so i hope it help you

 mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {

        @Override
        public boolean onMarkerClick(final Marker arg0) {

            // TODO Auto-generated method stub

            LatLng point = arg0.getPosition();
            CameraPosition cameraPosition1 = new CameraPosition.Builder()
                    .target(point)
                    .tilt(90)
                    .zoom(17)
                    .build();

            mMap.animateCamera(CameraUpdateFactory
                            .newCameraPosition(cameraPosition1));
            return true;
        }
     });

Upvotes: 2

Related Questions