Android - Google Maps api v2 - 禁用缩放控制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20753996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android - Google Maps api v2 - Disable Zoom control
提问by KickAss
How do I disable the Zoom In button on the Google Map?
如何禁用 Google 地图上的放大按钮?
I tried looking for commands like:
map.getUiSettings().setZoomControlsEnabled(true)...SOMETHING
but nothing exists.
我尝试寻找类似的命令:
map.getUiSettings().setZoomControlsEnabled(true)...SOMETHING
但什么都不存在。
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.
更新:我应该澄清一下,我只想禁用放大按钮,而不是整个缩放控制。
回答by Coderji
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.
不幸的是,您无法隐藏一个缩放按钮,您可以做的是隐藏两个按钮并创建您自己的自定义缩放控件并将它们放置在您的地图上。
回答by buxik
@Coderji said it's impossible. I say it's possible :-)
@Coderji 说这是不可能的。我说这是可能的:-)
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);
}
}
回答by Gabe
Call this on your GoogleMap
to get UiSettings
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap#getUiSettings()
调用它GoogleMap
以获取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)
然后setZoomControlsEnabled(false)
在UiSettings
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/UiSettings#setZoomControlsEnabled(boolean)