1

これで、osmdroidを使用して/ osmdroidに配置された独自のオフラインマップを表示するコードがあります。変更しようとしている他の特別なことは、最小ズームと最大ズームです。コードのこの部分を使用して、何も表示されません。

MapView mapview = (MapView) v.findViewById(R.id.mapview);
mapview.setUseDataConnection(false); 
final ITileSource tileSource = new XYTileSource("maps", ResourceProxy.string.mapnik, 18, 21, 256, ".png",
        "http://tile.openstreetmap.org/");

mapview.setBuiltInZoomControls(true);
mapview.setTileSource(tileSource);

しかし、私が設定したとき

setTileSource(TileSourceFactory.MAPNIK)

オフラインマップは正常に機能しますが、ズームに制限があります

XYTileSourceに何か問題がありますか?

前もって感謝します

4

2 に答える 2

2

これがosmdroidのxytilesourceの作業コードです。それが誰かに役立つことを願っています。

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);

        mapView.getController().setZoom(5);
        GeoPoint point = new LatLonPoint(6.83917,79.91455);
        //mapView.getController().setCenter(new GeoPoint(51500000, 5400000));
        mapView.getController().setCenter(point);
        final MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext());
        final ITileSource tileSource = new XYTileSource("SomeName", null, 3,14, 256, ".png",
                        "http://192.168.1.5/mapcache/tms/1.0.0/ms-base@GoogleMapsCompatible/");
        //mapView.setTileSource((new XYTileSource("localMapnik", Resource, 0, 18, 256, ".png", 
            //  "http://tile.openstreetmap.org/"))); 
        tileProvider.setTileSource(tileSource);
        final TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext());
        mapView.getOverlays().add(tilesOverlay);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    private static final class LatLonPoint extends GeoPoint {
        public LatLonPoint(double latitude, double longitude) {
            super((int) (latitude * 1E6), (int) (longitude * 1E6));
        }
    }

レイアウト ファイルには以下を含める必要があります

<org.osmdroid.views.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true" />
于 2013-06-01T16:08:48.273 に答える