mirror of
https://github.com/KeymonSoft/Durakelo_Reparto.git
synced 2026-04-17 19:37:04 +00:00
Commit inicial.
This commit is contained in:
128
mapas.bas
Normal file
128
mapas.bas
Normal file
@@ -0,0 +1,128 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=6.8
|
||||
@EndOfDesignText@
|
||||
#Region Activity Attributes
|
||||
#FullScreen: False
|
||||
#IncludeTitle: True
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
Dim GPS As GPS
|
||||
Dim rp As RuntimePermissions
|
||||
Dim ruta As String
|
||||
Dim skmt As SQL
|
||||
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
|
||||
Dim c As Cursor
|
||||
Dim latmarker As Double
|
||||
Dim longmarker As Double
|
||||
Private l_long As Label
|
||||
Private l_lat As Label
|
||||
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
|
||||
|
||||
'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
|
||||
|
||||
'permisos
|
||||
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
gmap.MyLocationEnabled = Result
|
||||
'fin de permisos
|
||||
|
||||
Dim JavaMapsObject As JavaObject
|
||||
JavaMapsObject = gmap.GetUiSettings
|
||||
JavaMapsObject.RunMethod("setMapToolbarEnabled", Array As Object(True))
|
||||
|
||||
'marcadores
|
||||
' Dim latmarker As Double =19.3931867
|
||||
' Dim longmarker As Double =-99.1439178
|
||||
latmarker = fila.LATITUD
|
||||
longmarker = fila.LONGITUD
|
||||
Dim marcador1 As Marker = gmap.AddMarker (latmarker,longmarker, "TIENDA")
|
||||
marcador1.Snippet = fila.NOMBRE
|
||||
'"Tienda 1"
|
||||
|
||||
|
||||
'posicion inicial
|
||||
Dim aa As CameraPosition
|
||||
aa.Initialize(latmarker,longmarker,15)''' RECOMENDABLE CAMBIAR A 10 SI ES MAS DE 1 MARCADOR
|
||||
gmap.AnimateCamera(aa)
|
||||
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
|
||||
GPS.Initialize("GPS")
|
||||
|
||||
If GPS.GPSEnabled = False Then
|
||||
ToastMessageShow("Debe Activar el GPS del Equipo.", True)
|
||||
StartActivity(GPS.LocationSettingsIntent)
|
||||
Else
|
||||
GPS.Start(0, 0)
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
GPS.Stop
|
||||
End Sub
|
||||
|
||||
Sub reg_Click
|
||||
StartActivity(fila)
|
||||
End Sub
|
||||
Reference in New Issue
Block a user