Sub Process_Globals
Dim GPS As GPS
'Dim D As DoubleTaptoClose
End Sub
Sub Globals
Private gmap As GoogleMap
Private MapFragment1 As MapFragment
Dim Latitud As Double = 0
Dim Longitud As Double = 0
Dim Lat2 As Double = 0
Dim Lon2 As Double = 0
Dim p1, p2 As Location
Dim Distance As Float
Dim boton1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
If MapFragment1.IsGooglePlayServicesAvailable = False Then
ToastMessageShow("Please install Google Play Services.", True)
End If
GPS.Initialize("GPS")
'Boton velocidad'
boton1.Initialize(0)
boton1.Text = 0 &" "&"km/h"
boton1.TextColor = Colors.Red
boton1.TextSize = 15
Activity.AddView(boton1, 40%x, 5dip, 25%x, 40dip)
'Fin Boton velocidad'
End Sub
Sub MapFragment1_Ready
gmap = MapFragment1.GetMap
Dim JavaMapsObject As JavaObject
JavaMapsObject = gmap.GetUiSettings
JavaMapsObject.RunMethod("setMapToolbarEnabled", Array As Object(True))
' Dim m1 As Marker = gmap.AddMarker(10, 30, "test")
' m1.Snippet = "This is the snippet"
Dim cp As CameraPosition
cp.Initialize(-33.469119900000000000 , -70.641997000000000000, 15)
gmap.AnimateCamera(cp)
End Sub
Sub GPS_LocationChanged (Parametro As Location)
Dim sp As Int
sp = Ceil(Parametro.Speed * 3.6)
boton1.Text = sp &" "&"km/h"
Latitud = Parametro.Latitude
Longitud = Parametro.Longitude
p2.Initialize2(Latitud,Longitud)
p1.Initialize2(Lat2, Lon2)
Distance = p1.DistanceTo(p2)
If Latitud <> 0 And Longitud <> 0 Then
If Distance > 10 Then
Lat2 = Latitud
Lon2 = Longitud
Dim cp As CameraPosition
cp.Initialize2(Parametro.Latitude, Parametro.Longitude, gmap.CameraPosition.Zoom, Parametro.Bearing, 0)
gmap.AnimateCamera(cp)
End If
End If
End Sub
Sub Activity_Resume
If GPS.GPSEnabled = False Then
ToastMessageShow("Debe Activar el GPS del Equipo.", True)
StartActivity(GPS.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
GPS.Start(0, 0) 'Listen to GPS with no filters.
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
GPS.Stop
End Sub