Osmdroid 6.0.2, cannot switch from SqlTileWriter to TileWriter (local storage)
See original GitHub issueHello. 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 to 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.
Trying to figure out what I am doing wrong I entered the realm of the libs code. I am not sure yet if this might be the issue as I do not have a full understanding of the code, but in the lib’s MapTileProviderBasic
lines 76 to 95 we have the following code:
if (cacheWriter != null) {
tileWriter = cacheWriter;
} else {
if (Build.VERSION.SDK_INT < 10) {
tileWriter = new TileWriter();
} else {
tileWriter = new SqlTileWriter();
}
}
final MapTileAssetsProvider assetsProvider = new MapTileAssetsProvider(
pRegisterReceiver, pContext.getAssets(), pTileSource);
mTileProviderList.add(assetsProvider);
final MapTileFileStorageProviderBase cacheProvider;
if (Build.VERSION.SDK_INT < 10) {
cacheProvider = new MapTileFilesystemProvider(pRegisterReceiver, pTileSource);
} else {
cacheProvider = new MapTileSqlCacheProvider(pRegisterReceiver, pTileSource);
}
mTileProviderList.add(cacheProvider);
In the last if
statement the cacheProvider
is basically version forced to a MapTileSqlCacheProvider
.
Could that be the problem or am I doing something wrong?
Issue Analytics
- State:
- Created 5 years ago
- Comments:17
@DimMad I’ve just merged #1174, which fixes your issue. Feel free to reopen this issue if needed.
@fariz-siracli I don’t think there’s a shortcut in osmdroid looking like your
MAP_TYPE_NONE
. I think the way to achieve what you want is by creating your own map tile provider as stated in my previous post. Please try this suggested solution, and if ever it doesn’t work, please do open a new issue as this one has nothing to do with your (legitimate) question.Guys i found solution. mMapView.getTileProvider().detach(); before adding any overlay could solve it. Thanks for attention.