Hi, i am a newbie. I try to implement a simple map view in my app using osmdroid.
I went through the tutorial https://www.b4x.com/android/forum/threads/osmdroid-mapview-for-b4a-tutorial.16310/
I tried for days to get maps. GmapCatcher mobac aso. Most of that stuff is blocked by the servers.
Others i dont catch cause of my poor experience.
I only found mbtyles available. After days of tryals to find a matching tutorial, i come up to you guys.
I am using OSMDroid_3_0_8_v3.60 and b4a 9.5.
Has someone a link for me or can help me to make mbtiles working in OSMDroid ?
I will give a donation for implementing a working code.
My Email :R.Wolf@Geopower.de
dus.mbtiles from MapTiler is in dir osmdroid on the phone
No Warnings, no Compiler errors.
I get a blank screen.
I went through the tutorial https://www.b4x.com/android/forum/threads/osmdroid-mapview-for-b4a-tutorial.16310/
I tried for days to get maps. GmapCatcher mobac aso. Most of that stuff is blocked by the servers.
Others i dont catch cause of my poor experience.
I only found mbtyles available. After days of tryals to find a matching tutorial, i come up to you guys.
I am using OSMDroid_3_0_8_v3.60 and b4a 9.5.
Has someone a link for me or can help me to make mbtiles working in OSMDroid ?
I will give a donation for implementing a working code.
My Email :R.Wolf@Geopower.de
dus.mbtiles from MapTiler is in dir osmdroid on the phone
No Warnings, no Compiler errors.
I get a blank screen.
B4X:
'#Region Activity Attributes
' #FullScreen: False
' #IncludeTitle: True
'#End Region
#Region activity Attributes
'#Region activityModule Attributes
#FullScreen: False
#IncludeTitle: True
'#ApplicationLabel: GPS
'#VersionCode: 1
'#VersionName:
'#SupportedOrientations: unspecified
#End Region
'#BridgeLogger: true
Sub Process_Globals
Dim MapCenter As GeoPoint
Dim ZoomLevel As Int
End Sub
Sub Globals
' Dim lblLon As Label
' Dim lblLat As Label
' Dim lblSpeed As Label
' Dim lblSatellites As Label
Dim MapView1 As MapView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Dim OfflineTileCacheFilename, TileCacheDir As String
'OfflineTileCacheFilename="offline_tile_cache_mapnik.zip"
OfflineTileCacheFilename="dus.mbtiles"
TileCacheDir=File.DirRootExternal&"/osmdroid"
' check if the offline tile cache has already been copied to the OSMDroid cache folder
If File.Exists(TileCacheDir, OfflineTileCacheFilename)=False Then
' create the 'osmdroid' cache folder if it does not exist
If File.Exists(TileCacheDir&"/", "")=False Then
File.MakeDir(File.DirRootExternal, "osmdroid")
End If
' copy the offline tile cache to the OSMDroid cache folder
File.Copy(File.DirAssets, OfflineTileCacheFilename, TileCacheDir, OfflineTileCacheFilename)
End If
End If
MapView1.Initialize("MapView1")
Activity.AddView(MapView1, 0, 0, 100%x, 100%y)
MapView1.SetMultiTouchEnabled(True)
MapView1.SetZoomEnabled(True)
' ensure that the map displays the Mapnik tiles
MapView1.SetTileSource("Mapnik")
' disable the data connection
MapView1.SetDataConnectionEnabled(False)
If FirstTime Then
MapCenter.Initialize(51.2277411, 6.7734556)
'MapCenter.Initialize(51.209142, 6.606045)
' choose a zoom level for which offline tiles exist
ZoomLevel=12
End If
MapView1.Zoom=ZoomLevel
MapView1.SetCenter3(MapCenter)
'Activity.LoadLayout("gps_basic")
End Sub
Sub Activity_Resume
If Starter.GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then CallSubDelayed(Starter, "StartGPS")
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
MapCenter=MapView1.GetCenter
ZoomLevel=MapView1.Zoom
CallSubDelayed(Starter, "StopGPS")
End Sub
Public Sub GpsStatus (Satellites As List)
Dim sb As StringBuilder
sb.Initialize
sb.Append("Satellites:").Append(CRLF)
For i = 0 To Satellites.Size - 1
Dim Satellite As GPSSatellite = Satellites.Get(i)
sb.Append(CRLF).Append(Satellite.Prn).Append($" $1.2{Satellite.Snr}"$).Append(" ").Append(Satellite.UsedInFix)
sb.Append(" ").Append($" $1.2{Satellite.Azimuth}"$).Append($" $1.2{Satellite.Elevation}"$)
Next
'lblSatellites.Text = sb.ToString
End Sub
Public Sub LocationChanged(Location1 As Location)
'MapCenter.Initialize( 51.198537, 6.570160)
' lblLat.Text = "Lat = " & Location1.Latitude
' lblLon.Text = "Lon = " & Location1.Longitude
' lblSpeed.Text = $"Speed = $1.2{Location1.Speed} m/s "$
'MapCenter.Initialize(Location1.Latitude,Location1.Longitude)
' Msgbox(Location1.Latitude, Location1.Longitude)
' MapView1.SendToBack
' MapView1.SetCenter(Location1.Latitude,Location1.Longitude)
End Sub
Sub MapView1_ZoomChanged
If MapView1.Zoom>12 Then
' i could have set the map zoom to 12 if it was more than 12 but this way you can see the level 12 tiles stretched to display where zoom level 13+ does not exist
ToastMessageShow("Tiles are cached for zoom levels 0 to 12 only, current zoom level is: "&MapView1.Zoom, False)
End If
End Sub