我正在尝试制作一个依赖离线地图的应用程序。Openstreet 地图成为我的选择,因为 OSMDroid 似乎被大量使用。但是,当我尝试使用离线地图(使用 Mobile Atlas 创建器生成的 MBTiles)时,“MapView”类不会在我的设备上显示任何地图。这是存在于片段中的片段。我也没有看到 logcat 抛出任何错误
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
String [] url = {"http://example.org/"};
XYTileSource MBTILESRENDER = new XYTileSource("mbtiles",
ResourceProxy.string.offline_mode,
1, 20, 256,
".png",
url);
DefaultResourceProxyImpl mResourceProxy = new DefaultResourceProxyImpl(getActivity());
SimpleRegisterReceiver simpleReceiver = new SimpleRegisterReceiver(getActivity());
File f = new File(Environment.getExternalStorageDirectory(), "osmdroid/srMbTiles.mbtiles");
Log.e("File ", f.toString() + " PATH:" + f.getAbsolutePath());
if ( f.exists() ) {
Log.d("DEBUG", " #### FIle Exists");
}
IArchiveFile[] files = { MBTilesFileArchive.getDatabaseFileArchive(f) };
MapTileModuleProviderBase moduleProvider = new MapTileFileArchiveProvider(simpleReceiver, MBTILESRENDER, files);
MapTileProviderArray mProvider = new MapTileProviderArray(MBTILESRENDER, null, new MapTileModuleProviderBase[] { moduleProvider });
myOpenMapView = new MapView(getActivity(),
256,mResourceProxy, mProvider);
myOpenMapView.setBuiltInZoomControls(true);
myOpenMapView.setTileSource(MBTILESRENDER);
IMapController controller = (IMapController) myOpenMapView.getController();
controller.setZoom(12);
getActivity().setContentView(myOpenMapView);
}
任何帮助将不胜感激。提前致谢