Search code examples
androidandroid-maps-v2android-maps-utils

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?


Solution

  • 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.