Search code examples
androiddictionaryosmdroid

Map won't scroll


I'm trying to create a simple map activity using osmdroid library
Map shows fine but it just won't scroll. I can't figure out what the problem is.

Here is the code:
Activity onCreate method

    setContentView(R.layout.activity_main);
    final MapView mapView = (MapView)findViewById(R.id.map);

    mapView.setBuiltInZoomControls(true);

    mapView.getController().setZoom(10);

    mapView.getController().setCenter(new GeoPoint(52.221, 6.893));

    ZoomControls mZoomControls = (ZoomControls)findViewById(R.id.zoomControls);
    mZoomControls.setOnZoomInClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mapView.getController().zoomIn();
        }
    });
    mZoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mapView.getController().zoomOut();
        }
    });

And xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >


<org.osmdroid.views.MapView
    android:id="@+id/map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"/>

<ZoomControls
    android:id="@+id/zoomControls"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="10dp" />

</RelativeLayout>

Solution

  • Remove

    android:clickable="true"
    

    from your MapView. See also Unable to pan or move the osmdroid map.