【发布时间】:2016-08-12 15:03:45
【问题描述】:
我已经成功使用 osmdroid-android-4.1.jar 一段时间来在我的应用程序中显示 OSM 地图图块。 现在,从昨天开始,我根本没有显示任何图块。当我将手机连接到 PC 时,我在日志中看到 403 禁止响应。我使用 Android Studio 在 Ubuntu 机器上构建了该应用程序。我对 .aar 文件还没有很好的理解,可能是 4.1jar 现在已经过时并且没有设置正确的用户代理吗?
我知道现在不支持 Mapquest,但我正在使用 Mapnik 瓦片
感谢所有信息
更新 我刚刚在我的 Windows PC 上尝试了一个基于 Eclipse 的旧项目。那使用 4.1 jar,我在模拟器中运行它。我看到相同的 403 响应并且没有地图图块。瓦片来源是
mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
我知道这个项目曾经奏效。缓存切片显示正常,但如果我移动地图 - 没有切片。
整个代码是
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)
*/
我之前已发布此代码作为答案,并作为最小的工作 osmdroid 示例的示例 - 现在它不是一个工作示例!
【问题讨论】: