Version 3.21 of OSMDroid supports the TilesOverlay
TilesOverlay is similar to the XYTileSource, you use it to add a new TileSource to your map.
A TilesOverlay however displays on top of the currently selected TileSource.
You use it to add a transparent tile layer to your map.
Take a look at this tile from the
OpenSeaMap project:
It's a transparent tile created so that it can be displayed on top of another tile layer.
This is the type of tile you'll use a TilesOverlay to display.
Some example code:
Code:
Sub Process_Globals
End Sub
Sub Globals
Dim MapView1 As MapView
Dim TilesOverlay1 As TilesOverlay
End Sub
Sub Activity_Create(FirstTime As Boolean)
If File.ExternalWritable=False Then
' OSMDroid requires the use of external storage to cache tiles
' if no external storage is available then the MapView will display no tiles
Log("WARNING NO EXTERNAL STORAGE AVAILABLE")
End If
MapView1.Initialize("")
MapView1.SetMultiTouchEnabled(True)
MapView1.SetZoomEnabled(True)
MapView1.Zoom=9
MapView1.SetCenter(53.024, 0.421)
Activity.AddView(MapView1, 0, 0, 100%x, 100%y)
' open sea map tiles are available from zoom levels 11 to 19
TilesOverlay1.Initialize("SeaMap", 11, 19, 256, ".png", "http://tiles.openseamap.org/seamark/")
' TilesOverlay1.LoadingBackgroundColor=Colors.LightGray
' TilesOverlay1.LoadingLineColor=Colors.DarkGray
MapView1.AddOverlay(TilesOverlay1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Load the MapView, displaying the default Mapnik tiles and displays the OpenSeaMap tiles on top ofthe Mapnik tiles.
You'll need to pan to an area of sea to see the OpenSeaMap tiles.
(There is a windfarm that should be visible in the demo code).
And you can uncomment the LoadingBackgroundColor and LoadingLineColor lines to experiment with those properties and see how they work.
Note that OpenSeaMap tiles do not exist for many areas and at many zoom levels.
Where an OpenStreetMap tile is requested and it does not exist, the MapView will (internally) generate a 404 tile not found error.
If the LoadingBackgroundColor is set to Colors.TRANSPARENT then no background color is displayed while waiting for a tile to load and there is no problem.
If you set a LoadingBackgroundColor that color is displayed until the requested tile has been downloaded.
So where tiles do not exist and fail to download you will see the background color persist and block the underlying Mapnik tiles.
I have not yet tried offline tiles with a TilesOverlay but it should work - the TilesOverlay should fetch tiles from any tiles archive in the osmdroid folder and display them instead of downloading tiles from the internet.
Martin.