2012-03-13 23 views
2

私はカスタムタイルを表示するためにOSMdroid apisを使用しています。彼らは同じもののためのGoogleラッパーを提供しています。だから、ここに私のローカルサーバーからosmdroid XYTileSourceがアンドロイドのサーバからタイルを表示しない

をタイルを表示しようとすると、私のコードは私が入れた場合、これは正常に動作し、次のよう

<com.google.android.maps.MapView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/mapview" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:clickable="true" 
android:apiKey="my API Key" 
/> 

でマップビューを宣言したレイアウトで

final MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext()); 
final ITileSource tileSource = new XYTileSource("SomeName", null, 3, 20, 256, ".png", 
        "http://MyServer/tiles/"); 
tileProvider.setTileSource(tileSource); 
final GoogleTilesOverlay tilesOverlay = new GoogleTilesOverlay(tileProvider, this.getBaseContext()); 
mapView.getOverlays().add(tilesOverlay); 

ですSDカードの下のタイルはと

mProvider = new MapTileProviderBasic(getApplicationContext()); 
mProvider.setTileSource(TileSourceFactory.FIETS_OVERLAY_NL); 
mTilesOverlay = new GoogleTilesOverlay(mProvider,getParent()); 
mTilesOverlay.setUseDataConnection(false); 
mTilesOverlay.useDataConnection(); 
mapView.getOverlays().add(mTilesOverlay); 
mapView.invalidate(); 

は誰も私MAKを助けてください、次のコードを使用します電子ここ

ラジ

+0

あなたは、URLが動作することを確認しまし含める必要がありますか? (デバイスのブラウザでURLを使用して、タイルが表示されていることを確認してください) – pootle

+0

はい、ブラウザに次のように入力するとurlが動作します。http://MyServer/tiles/15/x_y.png – Nik

+0

ログファイル?タイルをフェッチしようとしたときに何が起こっているのかを確認する必要があります。または、デバッガでコードをブレークポイントして、ファイルを取得しようとしたときに何が起こるかを確認できます。または、OSMタイルプロバイダを使用してみることもできます。サーバのログにタイルのリクエストが表示されますか? – pootle

答えて

0

この作品は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/[email protected]/"); 
     //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" /> 
関連する問題