2011-04-01 47 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) 
}