51

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.

KickAss
  • 4,210
  • 8
  • 33
  • 41

5 Answers5

130

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.

Coderji
  • 7,655
  • 5
  • 37
  • 51
  • Hi @Coderji, thanks for the reply. I should clarify, I want to disable only one button: Zoom In button. Is this possible? – KickAss Dec 24 '13 at 02:21
  • 1
    Ah okay, I was hoping to avoid creating my own, but fair enough, I shall do that. Thank you anyway – KickAss Dec 24 '13 at 02:28
  • 1
    Just to clarify. It remove the zoom button but the user still able to zoom in and out with fingers. Thanks mate. – Thiago Silva Apr 08 '20 at 21:55
8

@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);
        }
    }
buxik
  • 2,583
  • 24
  • 31
4

Call this on your GoogleMap to get UiSettings https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap#getUiSettings()

ThensetZoomControlsEnabled(false) on the UiSettings https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/UiSettings#setZoomControlsEnabled(boolean)

Gabe
  • 1,239
  • 1
  • 13
  • 20
  • 1
    Hey @Gabe, as I mentioned in another comment, I want to disable only the Zoom In button, not the whole object/element. – KickAss Dec 24 '13 at 02:23
2

In jetpack compose you can easily set zoomControlsEnabled = false

 GoogleMap(uiSettings = 
             MapUiSettings(
                zoomControlsEnabled = false
               )
              ) {}
        
user3630819
  • 21
  • 1
  • 1
0

In Kotlin you can use this code to enable

mMap.uiSettings.setZoomControlsEnabled(true)
Tippu Fisal Sheriff
  • 2,177
  • 11
  • 19