#Region Project Attributes
#ApplicationLabel: Navigation V1
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#AdditionalJar: com.google.android.gms:play-services-maps
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private rp As RuntimePermissions
Dim GPS As GPS
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
'NEW
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
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
'If gmap.IsInitialized = False Then
' Wait For MapFragment1_Ready
' gmap = MapFragment1.GetMap
' rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
' Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
'End If
' If Result Then
' gmap.MyLocationEnabled = True
'
' Else
' Log("No se concedió el Permiso")
' End If
If MapFragment1.IsGooglePlayServicesAvailable = False Then
ToastMessageShow("Por favor Instala Google Play Services", True)
End If
GPS.Initialize("GPS")
End Sub
Sub 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
gmap.MyLocationEnabled = True
Else
Log("No permission!")
End If
Dim mLat, mLon As Double
mLat = 26.081857
mLon = -98.294106
gmap.AddMarker2(mLat, mLon, "CyMEZ Zona Segura", 90.2)
gmap.AddMarker2(26.094362, -98.272633, "Algun texto1", 0)
gmap.AddMarker2(26.032302, -98.399677, "Algun texto2", 0)
gmap.AddMarker2(26.006315, -98.212312, "Robo de Vehiculos en ésta área", 0)
For i = 0 To 10 Step 1
'Test de Añadir Marcadores Sacados de Una Base de datos por ejemplo
gmap.AddMarker2(26.094362 + i, -98.272633 + i, "Test de prueba: " & i, (i * 10))
Next
'Dim JavaMapsObject As JavaObject
'JavaMapsObject = gmap.GetUiSettings
'JavaMapsObject.RunMethod("setMapToolbarEnabled", Array As Object(True))
' Dim cp As CameraPosition
'cp.Initialize(26.0558219,-98.3315649,13.08)'Ubicacion Municipio Reynosa
' cp.Initialize(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude, gmap.CameraPosition.Zoom)
' gmap.AnimateCamera(cp)
End Sub
Sub GPS_LocationChanged(Parametro As Location)
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("Activa el GPS Del Equipo", True)
' StartActivity(GPS.LocationSettingsIntent)
' Else
' GPS.Start(0,0)
'26.081857, -98.294106
'End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
GPS.Stop
End Sub