我想在我的Android应用程序中使用离线地图。所以我尝试在assets文件夹中添加.mbtiles文件。
Android Studio中我文件的路径:app> src> main> assets> vinnytsia.mbtiles
为了创建.mbtiles文件,我使用Mobile Atlas Creator。
这是我的代码:
mapView = (MapView) findViewById(R.id.mapview);
TileLayer mbTileLayer = new MBTilesLayer(this, "vinnytsia.mbtiles");
mapView.setTileSource(new ITileLayer[] {mbTileLayer});
mapView.setScrollableAreaLimit(mbTileLayer.getBoundingBox());
mapView.setMinZoomLevel(mapView.getTileProvider().getMinimumZoomLevel());
mapView.setMaxZoomLevel(mapView.getTileProvider().getMaximumZoomLevel());
mapView.setCenter(mapView.getTileProvider().getCenterCoordinate());
mapView.setZoom(4);
我的日志:
07-15 19:49:59.081 29344-29344/com.samusko.journeyproject E/MBTilesLayer﹕ MBTiles file not found in assets: java.io.FileNotFoundException: vinnytsia.mbtiles
07-15 19:49:59.171 29344-29344/com.samusko.journeyproject I/MapTileCache﹕ cacheDir previously created '/storage/emulated/0/Android/data/com.samusko.journeyproject/cache/mapbox_tiles_cache'
请帮我解决这个问题。 谢谢!