B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Activity
Version=9.95
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: FALSE
	
#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 String
	Dim longmarker As String
	Private l_long As Label
	Private l_lat As Label
	Private NOMBRE_TIENDA As String
	Private p_principal As Panel
	Private b_regresar As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
	Activity.LoadLayout("mapa_cliente")
	If MapFragment1.IsGooglePlayServicesAvailable = False Then
		ToastMessageShow("Please install Google Play Services.", True)
	End If
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))
	Dim marcador1 As Marker = gmap.AddMarker (latmarker,longmarker, "TIENDA")
	marcador1.Snippet = B4XPages.MainPage.cliente.NOMBRE
	'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)
'	GPS.Start(0, 0)
'	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
	Subs.centraBoton(b_regresar, Activity.Width)
	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
	Subs.centraPanel(p_principal, Activity.Width)
	p_principal.Height = Activity.Height	* 0.95
	latmarker = B4XPages.MainPage.cliente.LATITUD
	longmarker =  B4XPages.MainPage.cliente.LONGITUD
	NOMBRE_TIENDA = B4XPages.MainPage.cliente.NOMBRE
End Sub

Sub Activity_Pause (UserClosed As Boolean)
	GPS.Stop
End Sub

Sub reg_Click
'	StartActivity(fila)
	B4XPages.ShowPage("Cliente")
End Sub

Private Sub b_regresar_Click
	Log("Pressed")
	Activity.Finish
	B4XPages.ShowPage("Cliente")
End Sub