问题
I'm using the osmdroid map in a sample application. The map is seen,zoom works,and everything is fine except that i'm unable to pan/move the map.
My main xml code is:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<org.osmdroid.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true">
</org.osmdroid.views.MapView>
</RelativeLayout>
My java code is:
public class MapTest extends Activity {
private MapView mapView;
private MapController mapController;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_test);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(false);
mapView.setMultiTouchControls(true);
mapController = this.mapView.getController();
mapController.setZoom(10);
GeoPoint mapCenter = new GeoPoint(17.4467, 78.4667);
mapController.setCenter(mapCenter);
}
}
Any ideas as to how to enable the movement?
回答1:
Try removing:
android:clickable="true"
from your MapView. That makes the MapView consume touch events and it messes with the dispatchTouchEvent method. You might also try removing the focusable stuff too.
回答2:
mapView.setClickable(false);
It worked for me.
You should give it a shot.
回答3:
Just install previous version for now, looks like there's a bug in 3.0.9.
回答4:
Try to use
mapView.setClickable(false);
来源:https://stackoverflow.com/questions/15727055/unable-to-pan-or-move-the-osmdroid-map