【发布时间】:2014-04-03 15:44:01
【问题描述】:
我有使用 4.0 版的离线 osmdroid 地图。升级到 4.1,它们不再工作。我已将问题缩小到 XYTileSource,其中 aBaseUrl 从 4.0 中的字符串更改为 4.1 中的数组。如何让离线磁贴在 4.1 中工作?
有效的旧 4.0 代码。磁贴在 /sdcard/osmdroid/tiles.zip
XYTileSource ts = new XYTileSource ( "tiles",
ResourceProxy.string.offline_mode,
13,
17,
256,
".png",
"http://127.0.0.1");
mapView = (MapView) findViewById(R.id.mapview);
mapView.setTileSource(ts);
mapView.setMultiTouchControls(true);
mapView.setBuiltInZoomControls(false);
mapView.setUseDataConnection(false);
mapView.getController().setZoom(15);
GeoPoint point = new GeoPoint(40.715,-73.945);
mapView.getController().setCenter(point);
我尝试将其更改为此,但它不起作用。
String[] urls = {"http://127.0.0.1"};
XYTileSource ts = new XYTileSource ( "tiles",
ResourceProxy.string.offline_mode,
13,
17,
256,
".png",
urls);
【问题讨论】:
-
我认为 aBaseUrl 更改无关,尤其是因为您没有使用在线服务器。您应该尝试逐步检查磁贴提供者,看看他们是否正在返回磁贴。
-
在线提供商工作。这只是我使用的离线磁贴的相同代码,在 4.1 中不再适用。
-
我想我正在放弃 osmdroid 并将 Leaflet 放在 webview 中。它的性能要好得多,而且它可以仅从文件系统使用离线切片,而不是在 zip 中。 osmdroid 在处理大型 zip 文件时遇到内存问题。