Android - Google Maps api v2 - Disable Zoom control

AndroidGoogle MapsZooming

Android Problem Overview


How do I disable the Zoom In button on the Google Map?

I tried looking for commands like: map.getUiSettings().setZoomControlsEnabled(true)...SOMETHING but nothing exists.

I want to leave creating my own buttons for zooming as a last resort.

UPDATE: I should clarify, I only want to disable the Zoom In button, not the whole Zoom Control.

Android Solutions


Solution 1 - Android

the setting you used is right, but to disable it, it should be false.

map.getUiSettings().setZoomControlsEnabled(false);

hope I got your question right..

Edit

Unfortunately, you can't hide one zoom buttons, what you can do is hide both buttons and create your own custom zoom control and place them on the your map.

Solution 2 - Android

@Coderji said it's impossible. I say it's possible :-)

You can hide one of zoom button (+ or -) and perform on them all operations like in normal view (margins, size, padding, etc.)

    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);
        }
    }

Solution 3 - Android

Solution 4 - Android

In Kotlin you can use this code to enable

mMap.uiSettings.setZoomControlsEnabled(true)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKickAssView Question on Stackoverflow
Solution 1 - AndroidCoderjiView Answer on Stackoverflow
Solution 2 - AndroidbuxikView Answer on Stackoverflow
Solution 3 - AndroidGabeView Answer on Stackoverflow
Solution 4 - AndroidTippu Fisal SheriffView Answer on Stackoverflow