0

オフラインおよびオンライン機能を備えたosmDroidマッピングAPIを使用してAndroidマッピングアプリを開発したいのですが、それに関するチュートリアルがあまり見つからなかったため、osmdroidマッピングAPIをオフラインまたはオンラインで使用するチュートリアルへのリンクがあれば。デフォルトのプロバイダーからのマップを表示するためだけに小さなアプリを作成しましたが、アプリケーションは実行されますが、マップが表示されません(スカーのみ)。何が問題なのですか?コード:

MapView map = new MapView(this, 256);
    map.setClickable(true);
    map.setBuiltInZoomControls(true);
    setContentView(map);

コントロールが表示されます!!!!!!

4

3 に答える 3

1

おそらくタイルソースがありません。以下は、osmdroidを使用したOSMマップを表示するコードの最小サンプルです。

import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.app.Activity;
import android.os.Bundle;

// This is all you need to display an OSM map using osmdroid
public class OsmdroidDemoMap extends Activity {

    private MapView         mMapView;
    private MapController   mMapController;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            setContentView(R.layout.osm_main);
        mMapView = (MapView) findViewById(R.id.mapview);
        mMapView.setTileSource(TileSourceFactory.MAPNIK);
        mMapView.setBuiltInZoomControls(true);
        mMapController = mMapView.getController();
        mMapController.setZoom(13);
        GeoPoint gPt = new GeoPoint(51500000, -150000);
        //Centre map near to Hyde Park Corner, London
        mMapController.setCenter(gPt);

    }
}
/* HAVE THIS AS YOUR osm_main.xml
---------------------------------------------------------- XML START
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:id="@+id/mapview"
        ></org.osmdroid.views.MapView>
</LinearLayout>
---------------------------------------------------------- XML END
Include slf4j-android-1.5.8.jar and osmdroid-android-3.0.5.jar in the build path
(Google search for where to get them from)
*/
于 2012-04-15T14:06:06.890 に答える
1

それとも、マニフェスト ファイルに INTERNET (または別の) 権限がありませんか?

HowToUseJar

于 2012-04-16T07:46:01.113 に答える