Secondary tile overlay does not always display tiles
See original GitHub issueI’m using osmdoird 5.6.5 in my Android application. I’m using a custom baselayer, and I add a second layer above it in this way:
baselayer:
final MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext());
final ITileSource tileSource = new XYTileSource(getResources().getString(R.string.rp_cachemap), 6, 17, 256, ".png", tileserver);
tileProvider.setTileSource(tileSource);
final TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext());
tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
overlay:
final MapTileProviderBasic anotherTileProvider = new MapTileProviderBasic(getApplicationContext());
final ITileSource tileSource2 = new XYTileSource("tile_overlay_3",6, 17, 256, ".png", new String[]{"https://geoserver2.nodemapp.com/geoserver/"})
{
@Override
public String getTileURLString(MapTile aTile) {
String hello= getBaseUrl() + "gwc/service/gmaps?layers=nodemapp-public-mobile-with-cache&zoom=" + aTile.getZoomLevel() + "&x=" + aTile.getX() + "&y=" + aTile.getY() + "&format=image/png&viewparams=kind:hike;groupid:1&version=1";
System.out.println(hello);
return hello;
}
};
anotherTileProvider.setTileSource(tileSource2);
final TilesOverlay secondTilesOverlay = new TilesOverlay(anotherTileProvider, this.getBaseContext());
secondTilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
set tiles on map:
osmMap.setTileSource(tileSource);
osmMap.getOverlays().add(secondTilesOverlay);
osmMap.invalidate();
Eveything is working fine, but when scrolling the map, sometimes there are some tiles not showing properly in the second overlay. When scrolling a little bit further, they are loaded. Is this a known bug?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:13
Top Results From Across the Web
Custom Tiles overlay not working in latest Google Maps SDK ...
The issue was with the tile url. The first issue in that was that the url was http, requests to which were failing....
Read more >Overlay tiled images on a map - UWP applications
Overlay third-party or custom tiled images on a map by using tile sources. Use tile sources to overlay specialized information such as ...
Read more >Overlay Tile Names - BoardGameGeek
Does a list of the overlay tile names along with images of the tiles exist anywhere? I am attempting to organize the game...
Read more >MKTileOverlay not displayed on iOS… - Apple Developer
MKTileOverlay not displayed on iOS 14 device, but on iOS 14 Simulator. ... it to NO, but setting NO leads to only grey...
Read more >Square tile galleries show square images - WordPress.org
All the images in a square lightbox or circular tile galleries display in the overlay as square images. There are replicated Tiled galleries...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@conej730
According to Android docs about
invalidate
:In short:
invalidate
is not sync, and it’s safe to call several times as Android will refresh the display potentially only once. At some point.Back to the current issue.
We have async tile downloads, and a
MapView
. How do new tiles refresh theMapView
: only because whenever a tile is successfully downloaded, it calls (by default) aHandler
of classSimpleInvalidationHandler
, that explicitly callsMapView.invalidate
. Another way to refresh theMapView
is to move/pinch the map.And the problem so far with the secondary tile provider is that you have to explicitly tell your provider how to behave when a tile is successfully downloaded. If not you just ask it to download tiles into the cache, regardless of the display. And you don’t have to do it explicitly for the primary tile provider because it’s done in
MapView.setTileProvider
.Therefore you should add something like
in your code.
In the meanwhile I’m fixing the “Sample with tiles overlay and secondary tile overlay” demo that doesn’t work for the same reasons - I will PR within an hour.
Tell me if it works.
@conej730 Excellent!