如何禁用Google地图上的“放大”按钮?
我尝试寻找以下命令:
map.getUiSettings().setZoomControlsEnabled(true)...SOMETHING
但不存在。
我想留下创建自己的缩放按钮作为最后的手段。
更新:我应该澄清,我只想禁用放大按钮,而不是整个缩放控件。
答案 0 :(得分:118)
您使用的设置是正确的,但要禁用它,它应该是假的。
map.getUiSettings().setZoomControlsEnabled(false);
希望我的问题是对的..
修改强>
不幸的是,您无法隐藏一个缩放按钮,您可以做的是隐藏这两个按钮并创建自己的自定义缩放控件并将它们放在地图上。
答案 1 :(得分:7)
您可以隐藏其中一个缩放按钮(+或 - )并对其执行所有操作,例如普通视图(边距,大小,填充等)
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);
}
}
答案 2 :(得分:3)
在GoogleMap
上拨打此电话以获取UiSettings
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap#getUiSettings()
setZoomControlsEnabled(false)
上的UiSettings
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/UiSettings#setZoomControlsEnabled(boolean)
答案 3 :(得分:0)
在Kotlin中,您可以使用此代码启用
mMap.uiSettings.setZoomControlsEnabled(true)