Zach
Zach

Reputation: 10139

Programmatically Increase android Map Zoom Level

I am using this code to increase the zoom level of map when user taps on Cluster. It works when I tap on the first Cluster on Map but there after its not changing the zoom level. What I am expecting is to expand each cluster as user taps on it.

mClusterManager.setOnClusterClickListener(new ClusterManager.OnClusterClickListener<MyMapCluster>() {
            @Override
            public boolean onClusterClick(Cluster<MyMapCluster> cluster) {
                float currentZoom = getMap().getCameraPosition().zoom;
                getMap().animateCamera(CameraUpdateFactory.zoomTo(currentZoom*2));
                return false;
            }
        });

How to make this work?

Upvotes: 1

Views: 520

Answers (2)

Stephane Mathis
Stephane Mathis

Reputation: 6622

The zoom level goes from 1 to 21. And you are doubling it each time. So you must be too closed to be able to zoom further.

So if you start at the zoom 14 you can't double it.

Increase the zoom by adding 2 ( 14, 16, 18, 20, 21) each times.

Upvotes: 1

Ravindra Kushwaha
Ravindra Kushwaha

Reputation: 8042

Try below lines of code for it, it might be helpful for you.

  googleMap.getUiSettings().setZoomControlsEnabled(true);

  googleMap.animateCamera(CameraUpdateFactory.zoomTo(16), 5000, null);

Upvotes: 0

Related Questions