korujzade
korujzade

Reputation: 400

How to disable zoom out gesture in Google Maps Api v2 Android?

I can disable both zoom in/out gestures with mMap.getUiSettings().setZoomGesturesEnabled(false), but how can I disable just zoom out gesture?

Update

What I exactly need is to allow a user to view the map till the specified zoom level. For instance, if zoom level is set to 17, allow a user to zoom in and scroll around the map without leaving the area shown in the zoom level 17 and zoom out to level 17 again.

Upvotes: 1

Views: 654

Answers (1)

Arsen Sench
Arsen Sench

Reputation: 438

SupportMapFragment mapView = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map));
    View zoomControls = mapView.getView().findViewById(0x1);

    for(int i=0;i<((ViewGroup)zoomControls).getChildCount();i++){
        View child=((ViewGroup)zoomControls).getChildAt(i);
        if (i==0) {
            // there is your "+" button, zoom in

        }
        if (i==1) {
            // there is your "-" button, I hide it in this example
            child.setVisibility(View.GONE);
        }
    }

Upvotes: 1

Related Questions