0

osmdroid ライブラリを使用して単純なマップ アクティビティを作成しようとして
います。マップは正常に表示されますが、スクロールしません。何が問題なのかわかりません。

コードは次のとおりです:
Activity onCreate メソッド

    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();
        }
    });

そして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>
4

2 に答える 2

0

解決
策(私が見つけた)唯一の解決策は、代わりにフラグメントを使用し、そこでマップビューを膨らませることです

このようなもの:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    mResourceProxy = new ResourceProxyImpl(inflater.getContext()
            .getApplicationContext());
    mMapView = new MapView(inflater.getContext(), 256, mResourceProxy);
    mMapView.setUseSafeCanvas(true);
    mMapView.setBuiltInZoomControls(true);
    mMapView.setMultiTouchControls(true);
    mMapView.getController().setZoom(10); //set initial zoom-level, depends on your need
    mMapView.getController().setCenter(new GeoPoint(52.221, 6.893));
    return mMapView;
}
于 2013-06-02T09:29:41.153 に答える