j.Download($"https://mt1.google.com/vt/lyrs=r&x=${aX}&y=${aY}&z=${aZ}"$)
'Get Tile from internet openstreemap website
public Sub getTileFromInternet(aZ As Int,aX As Int,aY As Int) As ResumableSub
Dim j As HttpJob
Dim bmp As B4XBitmap
Try
j.Initialize("", Me)
' j.Download($"https://a.tile.openstreetmap.org/${aZ}/${aX}/${aY}.png"$)
j.Download($"https://mt1.google.com/vt/lyrs=r&x=${aX}&y=${aY}&z=${aZ}"$)
j.GetRequest.SetHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Try
bmp=j.GetBitmap
Catch
Log(LastException.Message)
End Try
End If
Catch
Log(LastException.Message)
End Try
If j.IsInitialized Then
j.Release
End If
Return bmp
End Sub
Google Maps: https://mt1.google.com/vt/lyrs=r&x={x}&y={y}&z={z}
Google Satellite: http://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga
Google Hybrid: https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}G
Google Traffic: https://mt1.google.com/vt?lyrs=h@159000000,traffic|seconds_into_week:-1&style=3&x={x}&y={y}&z={z}
Google Roads: https://mt1.google.com/vt/lyrs=h&x={x}&y={y}&z={z}
Proveedor Bing
Bing maps: http://ecn.dynamic.t0.tiles.virtualearth.net/comp/CompositionHandler/{q}?mkt=en-us&it=G,VE,BX,L,LA&shading=hill
Bing Satélite: http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=0&dir=dir_n’
Proveedor Esri
ESRI Imagery/Satellite: https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}
ESRI National Geographic: http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}
ESRI Physical: https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}
ESRI Streets: https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}
ESRI Terrain: https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}
ESRI Topo: https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}
ESRI Transportation: https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}
Dim sqlTiles As SQL
Sub AddMbTiles(filepath As String, filename As String)
'Log("AddMbTiles " & filepath & " " & filename)
If File.Exists(filepath, filename) Then
Log(filename & " is found")
sqlTiles.Initialize(filepath, filename, False)
CustomTileProvider1.Initialize(B4XPages.MainPage.PageMap, "Get_MbTile")
TileOverlayOptions1.Initialize
TileOverlayOptions1.SetTileProvider(CustomTileProvider1)
' sets to back so that polygons etc show
TileOverlayOptions1.SetZIndex(-1)
TileOverlay1 = GoogleMapsExtras1.AddTileOverlay(GoogleMap1, TileOverlayOptions1)
' Log("CustomTileProvider1.IsInitialized " & CustomTileProvider1.IsInitialized)
Else
Log(filename & " NOT found")
TileOverlay1.Remove
End If
End Sub
Sub Get_MbTile(TileX As Int, TileY As Int, Zoom As Int) As Tile
'Log("Get_MbTile X="&TileX&", Y"&TileY&", Zoom="&Zoom)
Dim Cursor1 As Cursor
Dim Buffer() As Byte
Dim newY As Int = adjustTmsY(TileY, Zoom)
Dim strSql As String = "Select tile_data from tiles where zoom_level = " & Zoom & " AND [tile_column] = " & TileX & " AND [tile_row] = " & newY & ";"
'Log(strSql)
Cursor1 = sqlTiles.ExecQuery(strSql)
Cursor1.Position = 0
Buffer = Cursor1.GetBlob("tile_data")
'Log("Buffer.Length " & Buffer.Length)
If Buffer.Length>1 Then
'Log("MbTile Found at X="&TileX&", newY"&newY&", Zoom="&Zoom)
Dim Tile1 As Tile
Tile1.Initialize(256,256,Buffer)
'Cursor1.Close
Return Tile1
Else
'Cursor1.Close
Return CustomTileProvider1.NO_TILE
End If
End Sub
Sub adjustTmsY(Y As Int, Zoom As Int) As Int
'Invert tile y origin from top To bottom of map google TMS to Mbtiles Y reference
'https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/
Dim ymax As Int = Bit.shiftleft(1,Zoom)
Return ymax - Y - 1
End Sub
type maps:
I tried but get errors, maybe links changed, can you update them?other;