osmdroid离线地图没有加载瓷砖

时间:2016-06-10 09:48:53

标签: android osmdroid offlineapps

我需要在App

中查看离线磁贴

我使用" Mobile Atlas Creator 2.0.0 beta 1" 配置下载了瓷砖

enter image description here

图块zip文件位于

/mnt/sdcard/osmdriod/tiles.zip

MyActivity代码如下

MapView mapView = new MapView(this); //constructor

    mapView.setTileSource(new XYTileSource("MapQuest", 0, 10, 256, ".png", new String[] {}));

    mapView.setClickable(true);
    mapView.setBuiltInZoomControls(true);
    mapView.getController().setZoom(1); //set initial zoom-level, depends on your need
    mapView.getController().setCenter(new GeoPoint(52.516667, 13.383333)); //This point is in Enschede, Netherlands. You should select a point in your map or get it from user's location.
    mapView.setUseDataConnection(false); //keeps the mapView from loading online tiles using network connection.
    setContentView(mapView);

并且AndriodManifest.xml具有这些权限

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

但是瓷砖没有显示在地图上

enter image description here 注意:

osmdroid版本 编译&#39; org.osmdroid:osmdroid-android:5.1@aar'

1 个答案:

答案 0 :(得分:1)

尝试打开您的osm zip文件并检查磁贴文件夹名称。此文件中的tiles文件夹名称必须与XYTileSource构造函数第一个参数相同。 如果文件夹将具有名称&#34; OpenStreetMap MapQuest&#34;例如你可能需要写这个:

mapView.setTileSource(new XYTileSource("OpenStreetMap MapQuest", 0, 10, 256, ".png", new String[] {}));