2011-04-01 48 views

回答

6

我发现这是setClickable(假);

0

如果您将地图视图嵌入到您的应用中,我认为您可以使用静态地图查看相同的地图。

+0

什么叫静态映射意味着SupportMapFragment用户交互? – Vincent 2011-04-05 10:07:03

+0

静态地图是特定位置的地图快照。您可以放大和缩小,但不能做很多事情。 – Vinay 2011-04-06 04:07:50

+1

给我更多关于你正在寻找什么的细节... – Vinay 2011-04-06 04:08:16

-2

也许这可能是一个解决方案:

mapView.setEnabled(假)

+1

不要执行任何操作 – Vincent 2011-04-01 14:38:52

2

你会想setClickable(false),但你也可能想setFocusable(false),以防止MapView获得焦点。

这可能是用户使用硬件导航按钮时的问题,因为如果MapView具有焦点,则上下左右按钮将滚动地图。

38

即使有一个公认的答案,只是提供我的答案,因为它没有帮助我。 mapView.setClickable(false)不会一直工作,就像您在scrollView中有mapView的情况一样。所以我在相同尺寸的mapView的上方创建了一个视图对象。

处理覆盖视图的onTouchListener,并将所有触摸事件传递给mapView(ScrollView)的父项,因此将所有触摸事件从mapView传递给scrollview。实现

还有一个方法是通过执行

mMap.getUiSettings().setAllGesturesEnabled(false); 
+0

适用于v2也映射片段! – Aphex 2015-11-08 19:27:06

8
mMap.getUiSettings().setScrollGesturesEnabled(false); 

这可以在地图

0

禁用移动我创建的延伸的MapView 并重写onInterceptTouchEvent方法customMapView。

public class customMapView extends MapView { 
    public customMapView(Context context) { 
     super(context); 
    } 

    public customMapView(Context context, AttributeSet attributeSet) { 
     super(context, attributeSet); 
    } 

    public customMapView(Context context, AttributeSet attributeSet, int i) { 
     super(context, attributeSet, i); 
    } 

    public customMapView(Context context, GoogleMapOptions googleMapOptions) { 
     super(context, googleMapOptions); 
    } 

    @Override 
    public boolean onInterceptTouchEvent(MotionEvent ev) { 

//  return super.onInterceptTouchEvent(ev); 
     return true; 
    } 

} 
1

我们可以停止MapView的或使用GoogleMapOptions

override fun onCreate(savedInstanceState: Bundle?) { 
     super.onCreate(savedInstanceState) 

     val mapOptions = GoogleMapOptions() 
     mapOptions.rotateGesturesEnabled(false) 
     mapOptions.zoomGesturesEnabled(false) 
     mapOptions.tiltGesturesEnabled(false) 
     mapOptions.scrollGesturesEnabled(false) 

     // Map View 
     val mapView = MapView(context, mapOptions) 
     mapView.onCreate(savedInstanceState) 

     // Or 
     val mapView = MapView(context 
     mapView.getMapAsync { googleMap -> 
      googleMap.uiSettings.setAllGesturesEnabled(false) 
     } 

     // Or Map Fragment 
     val mapFragment = SupportMapFragment.newInstance(mapOptions) 
}