OSMDroid does not show map

雨燕双飞 提交于 2019-12-25 11:40:23

问题


I have generated a sqlite tile via atlas generator(according to this guide), but when i using this tiles in OSMDroid , OSMDroid does not showing anything! I don't know what is the issue, i have checked everything like zoom levels, center locations and etc..

Here are my codes :

MapView map = (MapView) rootView.findViewById(R.id.map);

map.setTileSource(new XYTileSource(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "osmdroid" + File.separator + "tehran17.sqlite", 14, 17, 256, ".jpg", new String[] {}));
//....
map.setUseDataConnection(false);
IMapController mapController = map.getController();
mapController.setZoom(15);
GeoPoint startPoint = new GeoPoint(35.692855, 51.356535);
mapController.setCenter(startPoint);

I have checked needed permissions like read and write external, i have checked generated sqlite file and it seems it is OK.


回答1:


root cause: the Tile Source Name you're providing is the file path, not the actual name of the tile source. If you look at the database, each tile source is listed (assuming the osmdroid tile sqlite format) for each tile. I think the column name is "source" or "provider". That's the "name" of the XYZTileSource.




回答2:


I finally fixed the issue!
It is related to gradle, do not add OSMDROID from gradle, because it will not have access to external sd, download project source and add it as module to your app.



来源:https://stackoverflow.com/questions/34593047/osmdroid-does-not-show-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!