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

Tile source max/min zoom is ignored by tile pre-cacher #1416

NasaGeek opened this issue Oct 7, 2019 · 2 comments


Copy link

commented Oct 7, 2019

Issue Type

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

Description and/or steps/code to reproduce the problem

The MapTilePreCache class will attempt to pre-cache tiles from a tile source at zoom levels that the tile source does not support (as specified by its min/max zoom levels). This results in a lot of unnecessary requests being made by the library.

Is this behavior perhaps intentional? I'm currently hacking it out by checking the zoom level myself in the source's getTileURLString method and returning null for unsupported zoom levels, but I wanted to ensure this would not cause any unexpected bad behavior.


This was seen with a custom tile source but should also be present with any tile sources that don't disable the pre-cacher with the FLAG_NO_PREVENTIVE policy flag.

You can most easily see this by enabling the DebugMapTileDownloader ( Configuration.getInstance().setDebugMapTileDownloader(true);) and then viewing logcat as you zoom to unsupported zoom levels. You'll see the following output:

2019-10-07 14:29:10.126 2994-5201/com.example.package D/OsmDroid: SqlCache - Tile doesn't exist: TileSource/16/53625/32013 2019-10-07 14:29:10.127 2994-5201/com.example.package D/OsmDroid: Archives - Tile doesn't exist: /16/53625/32013 2019-10-07 14:29:10.127 2994-5201/com.example.package D/OsmDroid: Downloading Maptile from url: https://<url>/16/53625/32013.png 2019-10-07 14:29:10.178 2994-5201/com.example.package W/OsmDroid: Problem downloading MapTile: /16/53625/32013 HTTP response: Not Found 2019-10-07 14:29:10.178 2994-5201/com.example.package D/OsmDroid: https://<url>/16/53625/32013.png

If it's a bug, version(s) of android this affects:


Version of osmdroid the issue relates to:



This comment has been minimized.

Copy link

commented Oct 8, 2019

I'll have a look at it. If there's a zoom level test to add, it should be at the provider level, not specifically for the pre cache.

@monsieurtanuki monsieurtanuki self-assigned this Oct 8, 2019
monsieurtanuki added a commit that referenced this issue Oct 9, 2019
New class:
* `SampleUnreachableOnlineTiles`: demo checking if the zoom restriction for tiles is correctly applied, to be found under "More Samples / Tileproviders / Zoom Restricted Online Tiles (14-15)"

Impacted classes:
* `MapTileApproximater`: called new method `TileLoader.loadTileIfReachable` instead of `TileLoader.loadTile`
* `MapTileModuleProviderBase`: new method `isTileReachable`; new method `TileLoader.loadTileIfReachable`, to be called instead of direct calls to `TileLoader.loadTile`
* `MapTilePreCache`: called new method `TileLoader.loadTileIfReachable` instead of `TileLoader.loadTile`
* `SampleFactory`: added new demo `SampleUnreachableOnlineTiles`
monsieurtanuki added a commit that referenced this issue Oct 9, 2019
bug/#1416 - additional zoom check before tile download

This comment has been minimized.

Copy link

commented Oct 9, 2019

@NasaGeek Fixed by #1417
I think that your getTileURLString hack is OK (I mean, no side-effect), in the meanwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.