简体   繁体   English

Android中的Google地图应可缩放但不可滚动

[英]Google maps in android should be zoomable but not scrollable

I have implemented a MapView in android. 我已经在android中实现了MapView。 I need to achieve following things in maps 我需要在地图上实现以下目标

  1. Maps should not be scrollable (Achieved using setClickable() to false) 地图不应滚动(使用setClickable()设置为false即可实现)
  2. Maps should not be scrollable (as setClickable is false, Map is not zoomable) 地图不可滚动(因为setClickable为false,地图不可缩放)

Enable the zoom gestures on your map object and disable the scroll gestures: 在地图对象上启用缩放手势,并禁用滚动手势:

@Override
public void onMapReady(final GoogleMap googleMap) {
    googleMap.getUiSettings().setZoomGesturesEnabled(true);
    googleMap.getUiSettings().setScrollGesturesEnabled(false);
}

您可以使用以下方法禁用MapFragment滚动:

googleMap.getUiSettings().setScrollGesturesEnabled(false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM