Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting tilesource clears cache #1943

Open
leknesh opened this issue Oct 5, 2023 · 0 comments
Open

Setting tilesource clears cache #1943

leknesh opened this issue Oct 5, 2023 · 0 comments

Comments

@leknesh
Copy link

leknesh commented Oct 5, 2023

Issue Type

[X ] Question
[ ] Bug
[ ] Improvement
[ ] Build system related
[ ] Performance
[ ] Documentation

Description and/or steps/code to reproduce the problem

We have an implementation using a 3rd party tile source. I've been looking into optimizing this, and noticed that the tile caching doesn't work as I expected. If I open a map fragment, the tiles are downloaded and stored to cache. However, in navigating away from the map fragment and returning to it with the exact same map tiles displayed, the tiles are not found in cache and are downloaded from the source all over again.

Drilling into this, I noticed that the call to mapView.setTileSource(myTileSource) will in turn call mTileProvider.setTileSource(aTileSource).

From MapTileProviderBase.java:

public void setTileSource(final ITileSource pTileSource) {
        mTileSource = pTileSource;
        clearTileCache();
    }

So as far as I can tell, the cache is cleared whenever the custom tilesource is set. I assume this is why the same map tiles are downloaded every time the exact same map is opened? How can I avoid this, I have to set the tilesource at some point? Or have I misunderstood how the tile cache is supposed to work?

Version of osmdroid the issue relates to:

6.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant