#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private gmap As GoogleMap
Private MapFragment1 As MapFragment
Private rp As RuntimePermissions
Private StateMessage As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
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)
Log(Tracker.gpslong)
gmap.MyLocationEnabled = True
gmap.TrafficEnabled=True
'gmap.MyLocation.Initialize(Tracker.gpslat,Tracker.gpslong)
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)
gmap.MapType=gmap.MAP_TYPE_NORMAL
CameraPosition1.Initialize(gmap.MyLocation.Latitude,gmap.MyLocation.Longitude, 16)
gmap.AnimateCamera(CameraPosition1)
Sleep(2000)
CameraPosition1.Initialize(gmap.MyLocation.Latitude,gmap.MyLocation.Longitude, 18)
gmap.AnimateCamera(CameraPosition1)
'Dim m As Marker
'Dim bitmap As Bitmap
'bitmap= LoadBitmapResize(File.DirAssets,"small-axe.png",30dip,30dip,True)
'gmap.AddMarker3(gmap.MyLocation.Latitude,gmap.MyLocation.Longitude,"",LoadBitmapResize(File.DirAssets,"small-axe.png",30dip,30dip,True))
End If
Else
Log("No permission!")
End If
End Sub
Sub Activity_Resume
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
StartService(Tracker)
Else
ToastMessageShow("No permission...", True)
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
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
Sub MapFragment1_Click (Point As LatLng)
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Starter.flp.IsConnected = False Then
SetState("Location provider not available")
End If
If Result Then
Dim rs As ResumableSub = CallSub(Starter, "CheckLocationSettingStatus")
Wait For (rs) Complete (SettingsResult As LocationSettingsResult)
Dim sc As StatusCodes
Select SettingsResult.GetLocationSettingsStatus.GetStatusCode
Case sc.SUCCESS
SettingsAreGood
Case sc.RESOLUTION_REQUIRED
SetState("RESOLUTION_REQUIRED")
SettingsResult.GetLocationSettingsStatus.StartResolutionDialog("srd")
Wait For srd_ResolutionDialogDismissed(LocationSettingsUpdated As Boolean)
If LocationSettingsUpdated Then
SettingsAreGood
Else
SetState("Not enabled")
End If
Case Else
SetState("Not available")
End Select
Else
SetState("No permission")
End If
End Sub
Sub SettingsAreGood
SetState("Location enabled - waiting for updates")
CallSub(Starter, "StartLocationUpdates")
End Sub
Public Sub Location_Changed (loc As Location)
'lblLocation.Text = $"$1.2{loc.Latitude} / $1.2{loc.Longitude}"$
End Sub
Sub SetState (msg As String)
StateMessage = msg
'lblState.Text = "State: " & msg
'Log(lblState.Text)
End Sub