Android - Google Maps api v2 - Disable Zoom control

匿名 (未验证) 提交于 2019-12-03 02:54:01

问题:

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.

回答1:

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.



回答2:

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


回答3:

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)



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!