2016-08-12 16 views
2

OSMマップタイルを私のアプリケーションに表示するのに、osmdroid-android-4.1.jarを使用していました。 昨日から、私はすべてのタイルを表示していません。携帯電話をPCに接続すると、ログに403の禁止された応答が表示されます。 Android Studioを使ってUbuntuマシンにアプリを構築しました。私はまだ.aarファイルをよく理解していませんが、4.1jarが時代遅れであり、正しいユーザーエージェントを設定していない可能性がありますか?osmdroid MapTileDownloaderが403のHTTP応答を禁止しています

私はマップクエストは、現在サポートされていません知っているが、私はMAPNIKが

タイルにすべての情報を使用していは感謝して、私はちょうど私のWindows PC上の古いのEclipseベースのプロジェクトを試してみた更新

を受けました。それは4.1 jarを使用し、私はエミュレータで実行しました。同じ403応答と地図タイルは表示されません。タイルソースは

mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE)です。

私はこのプロジェクトがうまく機能していることを知っています。キャッシュタイルにはOkが表示されますが、マップを移動するとタイルは表示されません。

全体のコードは、私は答えとして最小作業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.DEFAULT_TILE_SOURCE); 
     mMapView.setBuiltInZoomControls(true); 
     mMapController = (MapController) mMapView.getController(); 
     mMapController.setZoom(13); 
     GeoPoint gPt = new GeoPoint(51500000, -150000); 
     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:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 
    <org.osmdroid.views.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" /> 
</LinearLayout> 
---------------------------------------------------------- XML END 
Include slf4j-android-1.5.8.jar and osmdroid-android-4.1.jar in the build path 
(Google search for where to get them from) 
*/ 

ある - まあ、それは今働い例ではありません!

答えて

1

今日は同じ問題がありました。

compile files('libs/osmdroid-android-4.2.jar') 

はbuild.gradleでは、我々はこれを変更し

compile 'org.osmdroid:osmdroid-android:[email protected]' 

そして、この追加:マップをロードする前に、

OpenStreetMapTileProviderConstants.setUserAgentValue(BuildConfig.APPLICATION_ID); 

を。

この問題の詳細については、 https://github.com/osmdroid/osmdroid/issues/366こちらをご覧ください。

これはあなたにも役立ちます。

+0

この情報をありがとう、これは私がaarファイルでコンパイルするとうまくいきました。私はEclipse/Ant環境からAndroid Studio/Gradleに移行していないので、私のところで多くのことを理解する必要があります。 – NickT

関連する問題