Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1") 'layout basic template
Wait For MapFragment1_Ready
gmap = MapFragment1.GetMap
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
Log(Tracker.gpslat) ' The tracker may not have a valid location at this time
Log(Tracker.gpslong) ' Same here
gmap.MyLocationEnabled = True ' You now enabled to use the MyLocation
' You should NOT initialize it by yourself
'gmap.MyLocation.Initialize(Tracker.gpslat,Tracker.gpslong)
' Wait for the MyLocation is known....
Do While gmap.MyLocation.IsInitialized = False
Log("Location not initialized... Sleep a while...")
Sleep(250)
Loop
If gmap.MyLocation.IsInitialized Then
Dim CameraPosition1 As CameraPosition 'CameraPosition1.Initialize2(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude, gmap.CameraPosition.Zoom, 0, 0)
CameraPosition1.Initialize(gmap.MyLocation.Latitude,gmap.MyLocation.Longitude, 17)
gmap.moveCamera(CameraPosition1)
End If
Else
Log("No permission!")
End If
End Sub
' This Sub gets called by the Tracker Service when a Location changes (GPS)
' See Tracker Service for details
Sub Update_Location(newloc As Location)
If newloc.IsInitialized Then
Dim CameraPosition1 As CameraPosition 'CameraPosition1.Initialize2(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude, gmap.CameraPosition.Zoom, 0, 0)
CameraPosition1.Initialize(newloc.Latitude,newloc.Longitude, 17)
gmap.moveCamera(CameraPosition1)
End If
End Sub