2013-01-19 2 views
1

Osmdroid MapView가 있습니다. 설정 한 경우에도Osmdroid에서 스크롤 사용 안 함

mapView.setClickable(false); 
mapView.setFocusable(false); 

지도를 계속 이동할 수 있습니다. 지도보기에서 모든 상호 작용을 사용 중지하는 간단한 방법이 있나요?

+0

당신이 해결책을 찾았나요? – Schrieveslaach

+0

불행히도 아닙니다. – dominik

답변

1

모든 상호 작용을 비활성화해야합니다

mapView.setEnabled(false); 

나는 해결책을 발견했습니다. OnTouchListener을 설정하여 터치 이벤트를 직접 처리해야합니다. 예를 들어,

public class MapViewLayout extends RelativeLayout { 

    private MapView mapView; 

    /** 
    * @see #setDetachedMode(boolean) 
    */ 
    private boolean detachedMode; 

    // implement initialization of your layout... 

    private void setUpMapView() { 
     mapView.setOnTouchListener(new OnTouchListener() { 
      @Override 
      public boolean onTouch(View v, MotionEvent event) { 
       if (detachedMode) { 
        if (event.getAction() == MotionEvent.ACTION_UP) { 
         // if you want to fire another event 
        } 

        // Is detached mode is active all other touch handler 
        // should not be invoked, so just return true 
        return true; 
       } 

       return false; 
      } 
     }); 
    } 

    /** 
    * Sets the detached mode. In detached mode no interactions will be passed to the map, the map 
    * will be static (no movement, no zooming, etc). 
    * 
    * @param detachedMode 
    */ 
    public void setDetachedMode(boolean detachedMode) { 
     this.detachedMode = detachedMode; 
    } 
} 
1

당신이 시도 할 수 :지도보기

+1

이 제안에 감사하지만 그것이 나를 위해 작동하지 않습니다. – dominik

1

간단한 해결책은 @Schrieveslaach처럼하지만,지도보기와 함께 할 수 있습니다 :

mapView.setOnTouchListener(new View.OnTouchListener() { 
    @Override 
    public boolean onTouch(View v, MotionEvent event) { 
     return true; 
    } 
});