【问题标题】:How to disable zoom out gesture in Google Maps Api v2 Android?如何在 Google Maps Api v2 Android 中禁用缩小手势?
【发布时间】:2016-10-11 11:13:51
【问题描述】:
我可以使用mMap.getUiSettings().setZoomGesturesEnabled(false) 禁用放大/缩小手势,但是如何禁用仅缩小手势?
更新
我真正需要的是允许用户查看地图直到指定的缩放级别。例如,如果缩放级别设置为 17,则允许用户在不离开缩放级别 17 中显示的区域的情况下放大和滚动地图,然后再次缩小到级别 17。
【问题讨论】:
标签:
android
google-maps
google-maps-api-2
【解决方案1】:
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);
}
}