osmdroid: TilesOverlay showing tiles at wrong positions when scrolling the map
Issue Type
[x] Bug
Description and/or steps/code to reproduce the problem
I have written an app with a map component, based on osmdroid 6.1.2. As long as I use only one “basic map” (e.g. MAPNIK, HIKEBIKEMAP, OpenTopo, etc) everything is OK. But as soon as an additional TilesOverlay comes into play (e.g. PUBLIC_TRANSPORT) there is a very strange effect: When the map is zoomed or scrolled, suddenly appears a wild mixture of tiles from MAPNIK and PUBLIC_TRANSPORT at wrong positions, mainly on more or less empty regions, like the sea area. With every movement of the map, the picture changes unpredictable.
Here is a screenshot (North Sea area close to the coasts of the Netherlands and Germany), which demonstrates the effect. The dynamic behaviour during the scroll process can’t be visualized here, but the static conditions are clearly visible in the upper left region of the screen.

This effect remains, even after all tiles are downloaded completely - checked with TileStates.getUpToDate(); mapView.invalidate(); doesn’t help either.
Code snippets:
// create background map
mapView = (MapView) findViewById(R.id.mapview);
mapView.setTileSource(TileSourceFactory.MAPNIK);
// create overlay map
MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext());
tileProvider.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT);
TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext());
tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
mapView.getOverlays().add(tilesOverlay);
// enable zoom
mapView.setMultiTouchControls(true);
mapView.setBuiltInZoomControls(false);
// initialize position + zoom level
IMapController mapController = mapView.getController();
GeoPoint geoPoint = new GeoPoint(53.6, 5.3); // north sea
mapController.setCenter(geoPoint);
mapController.setZoom(8.0);
and in the related layout.xml:
<org.osmdroid.views.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Btw: Other overlay types, such as Copyright, ScaleBar, Grid, Compass, MiniMap, etc. don’t cause these problems.
Any ideas, where this effect comes from and how to repair it?
Environment
Tested on different devices with android versions from 4.0.3, 4.1.2, 4.4.2, 8.0 up to 9.0, no difference concerning the effect
Version of osmdroid the issue relates to:
6.1.2
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 36 (2 by maintainers)
Commits related to this issue
- bug/#1509 - Android bug fixes for MapTileApproximater and transparent images Impacted classes: * `DefaultOverlayManager`: unrelated minor fix * `IMapTileProviderCallback`: unrelated minor refactoring... — committed to osmdroid/osmdroid by monsieurtanuki 4 years ago
- Merge pull request #1513 from osmdroid/bug/#1509 bug/#1509 - Android bug fixes for MapTileApproximater and transparent images — committed to osmdroid/osmdroid by monsieurtanuki 4 years ago
@spyhunter99 Thank you for release 6.1.6! @mikebravoyes Please test and close the issue if relevant.
I can cut one today
On Sat, Mar 7, 2020, 11:41 AM Michael L. Braun notifications@github.com wrote:
I’m glad it helped! I wouldn’t swear that all the other projects share the same terminology, though. Like “MapTileApproximater” 😃 Well, as far as I’m concerned the bug is fixed by #1513. As I suspected, it’s a fix for Android bugs regarding transparency.
Why should it happen only with PUBLIC_TRANSPORT?
For the moment, I believe that there’s an issue with the
MapTileApproximater(more specifically its static methodapproximateTileFromLowerZoom(BitmapDrawable, long, int)), around its use of theBitmapPool, that is triggered by specific PUBLIC_TRANSPORT data for specific zoom levels (for instance, I see no bug on zoom level 7 and below).Well, that’s enough for today.