question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Osmdroid 6.0.2, cannot switch from SqlTileWriter to TileWriter (local storage)

See original GitHub issue

Hello. 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:closed
  • Created 5 years ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
monsieurtanukicommented, Oct 26, 2018

@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.

0reactions
fariz-siraclicommented, Oct 30, 2018

Guys i found solution. mMapView.getTileProvider().detach(); before adding any overlay could solve it. Thanks for attention.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android - Osmdroid 6.0.2, switch from SqlTileWriter to ...
The images are actually downloading but the map shows just the loading background. In the logs I got StorageUtils telling me that the...
Read more >
Index (osmdroid-android 6.0.1 API) - Javadoc.io
enables you to add a listener for when the map is ready to go. ... Provides various methods for managing the local filesystem...
Read more >
osmdroid
When osmdroid downloads tiles, if the tile cannot be stored to disk, it will not be displayed to the user. Osmdroid needs a...
Read more >
[Solved]-Unable to enter text in Compose new Tweet box on ...
... How to move an item from a list box using selenium webdriver ... Android - Osmdroid 6.0.2, switch from SqlTileWriter to TileWriter...
Read more >
Pil tamamen dolduğunda dizüstü bilgisayar nasıl bip sesi çıkarır ...
... başlatın Android - Osmdroid 6.0.2, SqlTileWriter'dan TileWriter'a (yerel ... Ionic uygulamasında localStorage'ın performansı üzerindeki etkisi nedir?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found