I am playing around with Osmdroid for use in an application. I already have a tiles server and want to use those tiles. Looked into docs used setTileSource(new XYTileSource())
magic happened. I have to mention that the documentation is a bit stale on many parts.
The tiles of the aforementioned server are already used in the app in a different feature. As logic dictates I want to use the same cache location so that I do not have duplicates of the tiles in the system. Again through docs, used Configuration.getInstance().setOsmdroidTileCase(new File("path"))
and again everything is going just fine. This was not so easy though as the documentation refers to the Osmdroids Constants class which is changed in the latest stable.
Then last part is to change from the SqlTileWriter
to a normal TileWriter
as we already have the image files downloaded from the other feature. This is where I cannot figure it out. I am using:
MapTileProviderBasic tileProvider = new MapTileProviderBasic(getActivity(), new XYTileSource("My Tiles", 5, 16, 256, ".png",
new String[]{"SERVER_URL"}), new TileWriter());
mMap.setTileProvider(tileProvider);
and things get weird. The images are actually downloading but the map shows just the loading background. In the logs I got StorageUtils
telling me that the storage is not writable. Gave permissions to the app, now writable, still nothing. I noticed that except from the tiles folder the .db
files have been created but the tiles table is empty. I went back to the above code and replaced the new TileWriter()
with a new SQLTileWriter()
just for sanity check and the map works just fine, without any permissions.
So the main question. How do you change from SQL to storage TileWriter?
For anyone who might get stuck with this, I opened an issue in Osmdroid's Github page where we found and solved the issue. Take a look at this link for more info.