Sub Process_Globals
Private fMap As TMap
Private fxui As XUI
End Sub
Sub Globals
Private fcvMap As cvMap
Private shapes As List
Dim PrecLT,PrecLg, Lg, Lt As Double
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Mappa_OSM")
shapes.Initialize
DownloadTraceGPS ' sub
End sub
Sub DownloadTraceGPS
Private JobDownload As HttpJob
JobDownload.Initialize("JobDownload", Me)
JobDownload.Download(URL)
Wait For (JobDownload) JobDone(JobDownload As HttpJob)
If JobDownload.Success = True Then
Dim out As OutputStream = File.OpenOutput(Main.GlobalThisApp, Main.TraceWeb, False)
File.Copy2(JobDownload.GetInputStream, out)
out.Close
ReadShapes ' sub
ShowMap ' sub
end if
End sub
Sub ReadShapes
dim N as int
TextReader1.Initialize(File.OpenInput(Main.GlobalThisApp, Main.TraceWeb))
Do While Riga <> Null
Riga = TextReader1.ReadLine
ele = Regex.Split(",",Riga)
Lt=ele(0).trim
Lg= ele(1).trim
if N>0 then
shapes.Add(coMapUtilities.instanceShapeLine(fcvMap,coMapUtilities.initShapeLine(coMapUtilities.initLatLng( PrecLT,PrecLg),coMapUtilities.initLatLng(Lt, Lg),Colors.ARGB(128,255,0,255),2dip,"test")))
end if
N=N+1
PrecLT=Lt:PrecLg=Lg
Loop
TextReader1.Close
End sub
Sub ShowMap
Log(shapes.size) ' OK
' For Each ZZ As TMapShapeLine In shapes
' Log(ZZ.fLatLng1.fLat & " " & ZZ.fLatLng1.fLng & " TO " & ZZ.fLatLng2.fLat & " " & ZZ.fLatLng2.fLng)
' Next
fMap=coMapUtilities.initMap(coMapUtilities.initLatLng(lt, lg), ZoomLevel, CompassDirection, OfflineMode , ShowMenu, ShowGrid, ShowCenter, ShowLandmark, ShowCenterLatLon, ShowZoom, ShowScale, ShowCompass, ShowShapes, _
shapes, _
ShowGPS, FollowGPS,coMapUtilities.initGPS(coMapUtilities.initLatLng(0,0),0))
end sub
Sub Activity_Pause (UserClosed As Boolean)
fMap=fcvMap.map
End Sub
private Sub fcvmap_ready
fcvMap.TileServer="https://a.tile.openstreetmap.org/" ' default
fcvMap.UserAgent="User-AgentMozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0"
fcvMap.Map=fMap
'--- draw the map
fcvMap.draw
fcvMap.Map=fMap
fcvMap.draw
End Sub