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.

Screenshot_North_Sea

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

Most upvoted comments

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

@monsieurtanuki https://github.com/monsieurtanuki Following these instructions https://github.com/osmdroid/osmdroid/wiki/How-to-build-osmdroid-from-source, after several hours I was able to succeed with the section “Building with Gradle”. But the next step “Building osmdroid with Android Studio” failed with the following error message:

Unsupported Modules Detected Compilation is not supported for following modules: osmdroid. Unfortunately you can’t have non-Gradle Java modules and Android-Gradle modules in one project.

Rather frustrating experience - like poking around in the dark. I give up and wait for the next release. Sooner or later it will appear.

Thank you for your patient support. The communication with you was a real pleasure 😃

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/osmdroid/osmdroid/issues/1509?email_source=notifications&email_token=AAPCIGNWICXPV65LDKMJI53RGJ2J7A5CNFSM4LAGMDNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOD52OY#issuecomment-596106555, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPCIGKXSF7ONSNL5QOAXTLRGJ2J7ANCNFSM4LAGMDNA .

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?

  • because not too long ago they had some problems and sent irrelevant tiles (e.g. wrong zoom levels), that are now cached on your system and not expired yet (mere hypothesis) => clearing the cache might be an option
  • because their tiles are special (e.g. very small), which brings a specific side effect

For the moment, I believe that there’s an issue with the MapTileApproximater (more specifically its static method approximateTileFromLowerZoom(BitmapDrawable, long, int)), around its use of the BitmapPool, 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.