Files
Kelloggs_v4/B4A/C_Mapas.bas
Jose Alberto Guerra Ugalde af1f4b9ead VERSION 5.12.18
- Se agrego auditoria en los "principales" eventos, se guardan en la tabla "auditoria"
2025-12-22 11:47:23 -06:00

140 lines
3.8 KiB
QBasic

B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=11.5
@EndOfDesignText@
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
'//Process Globals
Dim GPS As GPS
Dim rp As RuntimePermissions
Dim ruta As String
'//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 String
Dim longmarker As String
Private l_long As Label
Private l_lat As Label
Private NOMBRE_TIENDA As String
Dim logger As Boolean = True
End Sub
'You can add more parameters here.
Public Sub Initialize As Object
Return Me
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
Root.LoadLayout("mapas")
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
Root.AddView(boton1, 40%x, 5dip, 25%x, 40dip)
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub B4XPage_Appear
B4XPages.MainPage.aud.guarda("Entrada a Mapas")
GPS.Initialize("GPS")
Log(1)
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
gmap.MyLocationEnabled = Result
Log(2)
Log(gmap.MyLocationEnabled)
If GPS.GPSEnabled = False Then
ToastMessageShow("Debe Activar el GPS del Equipo.", True)
StartActivity(GPS.LocationSettingsIntent)
Else
GPS.Start(0, 0)
End If
latmarker = B4XPages.MainPage.cliente.LATITUD
longmarker = B4XPages.MainPage.cliente.LONGITUD
NOMBRE_TIENDA = B4XPages.MainPage.cliente.NOMBRE
If logger Then Log($"lat=${latmarker}, lon=${longmarker}"$)
If logger Then Log(gmap)
Log($"${gmap.IsInitialized} And ${gmap.MyLocationEnabled}"$)
If gmap.IsInitialized And gmap.MyLocationEnabled Then
gmap.Clear
MapFragment1_Ready
End If
If Not(Starter.Logger) Then logger = False
End Sub
Sub B4XPage_CloseRequest As ResumableSub
Log("Vamos a Cliente")
' BACK key pressed
' Return True To close, False To cancel
Subs.iniciaActividad("Cliente")
' Return True
Return False
End Sub
Sub MapFragment1_Ready
LogColor("MapReady", Colors.red)
gmap = MapFragment1.GetMap
' rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
' gmap.MyLocationEnabled = Result
gmap.Clear
Dim JavaMapsObject As JavaObject
JavaMapsObject = gmap.GetUiSettings
JavaMapsObject.RunMethod("setMapToolbarEnabled", Array As Object(True))
'marcadores
If latmarker = "null" Or latmarker = Null Or latmarker = "" Then 'Zocalo
latmarker = "19.432568527069805"
longmarker = "-99.13335030112772"
End If
If logger Then Log($"lat=${latmarker}, lon=${longmarker}"$)
Dim marcador1 As Marker = gmap.AddMarker(latmarker, longmarker, "TIENDA")
marcador1.Snippet = B4XPages.MainPage.cliente.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)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
GPS.Stop
End Sub
Sub reg_Click
Subs.iniciaActividad("Cliente")
End Sub