B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Activity
Version=9.3
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: False
#End Region

'Activity module
Sub Process_Globals
	Dim GPS As GPS
	Dim rp As RuntimePermissions
'	Dim skmt As SQL
	Dim c As Cursor
	Dim c2 As Cursor
	Dim c22 As Cursor
	Dim c3 As Cursor
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 HUE_BLUE As Float
	Dim HUE_RED As Float
	Dim HUE_GREEN As Float
	Private B_AZUL As Button
	Private B_ROJO As Button
	Private B_VERDE As Button
	Private B_TODOS As Button
	Dim Tienda As String
	Dim ruta, rutaAnt As String
	Dim LatitudRu As Double
	Dim LongitudRU As Double
	Dim LIST_AZUL As List
	Dim LIST_ROJO As List
	Dim LIST_VERDE As List
	Dim MARK_AZUL As Marker
	Dim MARK_ROJO As Marker
	Dim MARK_VERDE As Marker
	Dim MARK_CEDIS As Marker
	Dim rojo As String
	Dim azul As String
	Dim verde As String
	Dim todos As String
	Dim NumSerie As Int
	Dim OnInfoWindowClickListener1 As OnInfoWindowClickListener
	Dim GoogleMapEXTRA As GoogleMapsExtras
	Dim CODIGO As String
	Private SEMANA As String
'	Dim ruta As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
'	Msgbox("0","AVISO")
	Activity.LoadLayout("MAPA_RUTAS")
'	ruta = Main.ruta
'	If File.Exists(RUTA, "kmt.db") = False Then
'		File.Copy(File.DirAssets, "kmt.db", RUTA, "kmt.db")
'	End If
'	skmt.Initialize(Starter.ruta,"kmt.db", True)
	'GPS
'	If(FirstTime) Then
'		GPS.Initialize("GPS")
'	End If
'	Msgbox("0.0","AVISO")
	If MapFragment1.IsGooglePlayServicesAvailable = False Then
		ToastMessageShow("Please install Google Play Services.", True)
	End If
'	Msgbox("0.1","AVISO")
	'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'
	'MARK_CEDIS.IsInitialized
	MARK_AZUL.IsInitialized
	MARK_ROJO.IsInitialized
	MARK_VERDE.IsInitialized
	
	LIST_AZUL.Initialize
	LIST_ROJO.Initialize
	LIST_VERDE.Initialize

	verde = 0
	azul = 0
	rojo = 0
	todos = 1
'	c=skmt.ExecQuery2("select count(*) AS CUANTOS from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA"))
'	c.Position =0
'	SEMANA = c.GetString("CUANTOS")
'	c.Close
'	
'	If SEMANA > 0 Then
'		c=skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA"))
'		c.Position =0
'		SEMANA = c.GetString("CAT_VA_VALOR")
'		c.Close
'	End If

'	Msgbox("0.2","AVISO")
End Sub

Sub MapFragment1_Ready
	gmap = MapFragment1.GetMap
	gmap.IsInitialized
	
	'	ESTE CODIGO PARA LONGCLICK TOOLTIP
	If gmap.IsInitialized Then ' Esto es para capturar el "clic largo" de la etiqueta de los marcadores.
		Dim jo As JavaObject = gmap
		Dim event As Object = jo.CreateEventFromUI("com.google.android.gms.maps.GoogleMap.OnInfoWindowLongClickListener", "InfoWindowLongClick", Null)
		jo.RunMethod("setOnInfoWindowLongClickListener", Array(event))
	End If
	
	rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
	Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
	gmap.MyLocationEnabled = Result

	Dim JavaMapsObject As JavaObject
	JavaMapsObject = gmap.GetUiSettings
	JavaMapsObject.RunMethod("setMapToolbarEnabled", Array As Object(True))
	'''''''----------------------------MARKER AZUL - POR ENTREGAR
	Private esteAzul As Int = 0
	Private esteAzul2 As String
	If azul = 1 Or todos = 1  Then
		c.IsInitialized
		c = Starter.skmt.ExecQuery("select CAT_CL_CODIGO, IFNULL(SECUENCIA,0) AS SECUENCIA, CAT_CL_NOMBRE, CAT_CL_LAT, CAT_CL_LONG, CAT_CL_RUTA from kmt_info where gestion = 0 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 AND CAT_CL_CODIGO <> 63403 order by CAT_CL_RUTA")
		rutaAnt = ""
		For i = 0 To c.RowCount -1
			c.Position = i
			LatitudRu = c.GetString("CAT_CL_LAT")
			LongitudRU = c.GetString("CAT_CL_LONG")
			CODIGO=c.GetString("CAT_CL_CODIGO")
			Tienda= c.GetString("CAT_CL_NOMBRE")
			ruta = c.GetString("CAT_CL_RUTA")
			If c.GetString("SECUENCIA") = "null" Then
				NumSerie = 0
			Else
				NumSerie = c.GetString("SECUENCIA")
			End If
			Private s As Cursor = Starter.skmt.ExecQuery($"select indice from waypoints where codigo = '${CODIGO}'"$)
			If s.RowCount > 0 Then
				s.Position = 0
				NumSerie = s.GetString("indice")
			End If
			If rutaAnt <> ruta Then esteAzul = esteAzul + 1
'			If esteAzul = 1 Then esteAzul2= NumSerie&"marker-azul.png"
'			If esteAzul = 2 Then esteAzul2= NumSerie&"marker-azul1.png"
'			If esteAzul = 3 Then esteAzul2= NumSerie&"marker-azul2.png"
'			If esteAzul = 4 Then esteAzul2= NumSerie&"marker-azul3.png"
'			If esteAzul = 5 Then esteAzul2= NumSerie&"marker-azul4.png"
			
			Dim pedidos As Cursor = Starter.skmt.ExecQuery2("select * from HIST_VENTAS WHERE HVD_CLIENTE = ?", Array As String(c.GetString("CAT_CL_CODIGO")))
			Log(c.GetString("CAT_CL_CODIGO")&"   "& pedidos.RowCount)
			If pedidos.RowCount > 1 Then
				
				If esteAzul = 1 Then esteAzul2= "marker-azul.png"
				If esteAzul = 2 Then esteAzul2= "marker-azul1.png"
				If esteAzul = 3 Then esteAzul2= "marker-azul2.png"
				If esteAzul = 4 Then esteAzul2= "marker-azul3.png"
				If esteAzul = 5 Then esteAzul2= "marker-azul4.png"
				If esteAzul = 6 Then esteAzul2= "marker-azul1.png"
			
			Else If pedidos.RowCount = 1 Then
				
				pedidos.Position = 0 
				If pedidos.GetString("HVD_PRONOMBRE") = "Cobranza Pendiente" Then
					If esteAzul = 1 Then esteAzul2= "marker-amarillo.png"
					If esteAzul = 2 Then esteAzul2= "marker-amarillo.png"
					If esteAzul = 3 Then esteAzul2= "marker-amarillo.png"
					If esteAzul = 4 Then esteAzul2= "marker-amarillo.png"
					If esteAzul = 5 Then esteAzul2= "marker-amarillo.png"
					If esteAzul = 6 Then esteAzul2= "marker-amarillo.png"
				Else 
					If esteAzul = 1 Then esteAzul2= "marker-azul.png"
					If esteAzul = 2 Then esteAzul2= "marker-azul1.png"
					If esteAzul = 3 Then esteAzul2= "marker-azul2.png"
					If esteAzul = 4 Then esteAzul2= "marker-azul3.png"
					If esteAzul = 5 Then esteAzul2= "marker-azul4.png"
					If esteAzul = 6 Then esteAzul2= "marker-azul1.png"
				End If
				
			End If
'			MARK_VERDE = gmap.AddMarker3(LatitudRu,LongitudRU,CODIGO, Subs.CreateBitmapWithNumber(LoadBitmap(File.DirAssets, "marker-verde.png"), i+350))

'			Log(ruta & "|" & esteAzul & "|" & esteAzul2)
'			Log(NumSerie&" "& Tienda&" --------"& esteAzul2&" --------"&esteAzul)
			MARK_AZUL = gmap.AddMarker3(LatitudRu,LongitudRU,CODIGO, Subs.CreateBitmapWithNumber(LoadBitmap(File.DirAssets, esteAzul2), NumSerie))
			MARK_AZUL.Snippet = "R: " & ruta & " - " & Tienda
			rutaAnt = ruta
		Next
		c .Close
		If MARK_AZUL.IsInitialized Then LIST_AZUL.Add(MARK_AZUL)
	End If
	'''''''----------------------------MARKER VERDE- ENTREGADO
	If verde = 1 Or todos = 1  Then
		rutaAnt = ""
		c2.IsInitialized
		c2=Starter.skmt.ExecQuery("select CAT_CL_CODIGO, IFNULL(SECUENCIA,0) AS SECUENCIA, CAT_CL_NOMBRE, CAT_CL_LONG, CAT_CL_LAT, CAT_CL_RUTA from kmt_info where gestion = 2 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 AND CAT_CL_CODIGO <> 63403 order by CAT_CL_RUTA")
		For i = 0 To c2.RowCount -1
			c2.Position = i
			LongitudRU = c2.GetString("CAT_CL_LONG")
			LatitudRu = c2.GetString("CAT_CL_LAT")
			CODIGO=c2.GetString("CAT_CL_CODIGO")
			Tienda= c2.GetString("CAT_CL_NOMBRE")
			ruta = c2.GetString("CAT_CL_RUTA")
			If c2.GetString("SECUENCIA") = "null" Then
				NumSerie = 0
			Else
				NumSerie = c2.GetString("SECUENCIA")
			End If
			Private s As Cursor = Starter.skmt.ExecQuery($"select indice from waypoints where codigo = '${CODIGO}'"$)
			If s.RowCount > 0 Then
				s.Position = 0
				NumSerie = s.GetString("indice")
			End If
			MARK_VERDE = gmap.AddMarker3(LatitudRu,LongitudRU,CODIGO, Subs.CreateBitmapWithNumber(LoadBitmap(File.DirAssets, "marker-verde.png"), NumSerie))
'			MARK_VERDE = gmap.AddMarker3(LatitudRu,LongitudRU,CODIGO,LoadBitmapResize(File.DirAssets, NumSerie&"marker-verde.png" ,72, 115, True))
			MARK_VERDE.Snippet = "R:" & ruta & ", " & Tienda
		Next
	Else
		If verde = 1 Or todos = 1  Then
			rutaAnt = ""
			c2.IsInitialized
			c2=Starter.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE, CAT_CL_LONG, CAT_CL_LAT, CAT_CL_RUTA from kmt_info where gestion = 2 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 AND CAT_CL_CODIGO <> 63403 order by CAT_CL_RUTA")
			For i = 0 To c2.RowCount -1
				c2.Position = i
				LongitudRU = c2.GetString("CAT_CL_LONG")
				LatitudRu = c2.GetString("CAT_CL_LAT")
				CODIGO=c2.GetString("CAT_CL_CODIGO")
				Tienda= c2.GetString("CAT_CL_NOMBRE")
				ruta = c2.GetString("CAT_CL_RUTA")
				MARK_VERDE = gmap.AddMarker2(LatitudRu,LongitudRU, CODIGO,gmap.HUE_GREEN)
				MARK_VERDE.Snippet = "R:" & ruta & ", " & Tienda
			Next
			c2 .Close
			If MARK_VERDE.IsInitialized Then LIST_VERDE.Add(MARK_VERDE)
		End If
	End If
'	'''''''----------------------------MARKER ROJO - NO ENTREGADO
	Private esteRojo As Int = 0
	Private esteRojo2 As String
	If rojo = 1 Or todos = 1 Then
		rutaAnt = ""
		c3.IsInitialized
		c3=Starter.skmt.ExecQuery("select CAT_CL_CODIGO, IFNULL(SECUENCIA,0) AS SECUENCIA, CAT_CL_NOMBRE, CAT_CL_LONG, CAT_CL_LAT, CAT_CL_RUTA from kmt_info where gestion = 3 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 AND CAT_CL_CODIGO <> 63403 order by CAT_CL_RUTA")
		For i = 0 To c3.RowCount -1
			c3.Position = i
			LongitudRU = c3.GetDouble("CAT_CL_LONG")
			LatitudRu = c3.GetDouble("CAT_CL_LAT")
			Tienda= c3.GetString("CAT_CL_NOMBRE")
			ruta = c3.GetString("CAT_CL_RUTA")
			CODIGO=c3.GetString("CAT_CL_CODIGO")
			If c3.GetString("SECUENCIA") = "null" Then
				NumSerie = 0
			Else
				NumSerie = c3.GetString("SECUENCIA")
			End If
			Private s As Cursor = Starter.skmt.ExecQuery($"select indice from waypoints where codigo = '${CODIGO}'"$)
			If s.RowCount > 0 Then
				s.Position = 0
				NumSerie = s.GetString("indice")
			End If
			MARK_ROJO = gmap.AddMarker3(LatitudRu,LongitudRU,CODIGO, Subs.CreateBitmapWithNumber(LoadBitmap(File.DirAssets, "marker-rojo.png"), NumSerie))
'			MARK_ROJO = gmap.AddMarker3(LatitudRu,LongitudRU,CODIGO,LoadBitmapResize(File.DirAssets, NumSerie&"marker-rojo.png" ,72, 115, True))
			
			MARK_ROJO.Snippet= "R:" & ruta & ", " & Tienda
		Next
	Else
		If rojo = 1 Or  todos = 1  Then
			rutaAnt = ""
			c3.IsInitialized
			c3=Starter.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE, CAT_CL_LONG, CAT_CL_LAT, CAT_CL_RUTA from kmt_info where gestion = 3 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 AND CAT_CL_CODIGO <> 63403 order by CAT_CL_RUTA")
			For i = 0 To c3.RowCount -1
				c3.Position = i
				LongitudRU = c3.GetDouble("CAT_CL_LONG")
				LatitudRu = c3.GetDouble("CAT_CL_LAT")
				Tienda= c3.GetString("CAT_CL_NOMBRE")
				ruta = c2.GetString("CAT_CL_RUTA")
				CODIGO=c3.GetString("CAT_CL_CODIGO")
				MARK_ROJO = gmap.AddMarker2(LatitudRu,LongitudRU, CODIGO,gmap.HUE_RED)
				MARK_ROJO.Snippet= "R:" & ruta & ", " & Tienda
			Next
			If MARK_ROJO.IsInitialized Then LIST_ROJO.Add(MARK_ROJO)
			c3.Close
		End If
	End If
	''------------------------------
'	MARK_CEDIS = gmap.AddMarker3("19.3961802","-99.0784293","CEDIS", LoadBitmap(File.DirAssets, "marker-azul-0.png"))
'	If  MARK_VERDE.Visible Or MARK_ROJO.Visible  Then
'		MARK_CEDIS.Remove
'	End If
	Dim aa As CameraPosition
	aa.Initialize(LatitudRu,LongitudRU,15)''' RECOMENDABLE CAMBIAR A 10 PARA QUE SE VEAN MAS MARCADORES
	gmap.AnimateCamera(aa)

	'''''---------------------- ESTO ES PARA LOS CLICK EN LAS VENTANAS D INFORMACION-----------
	Dim OnInfoWindowClickListener1 As OnInfoWindowClickListener
	OnInfoWindowClickListener1.Initialize("OnInfoWindowClickListener1")
	GoogleMapEXTRA.SetOnInfoWindowClickListener(gmap, OnInfoWindowClickListener1)
End Sub

''''--------------------------				PRUEBA CON MARKER _CLICK
Sub OnInfoWindowClickListener1_click(Marker1 As Marker)
	Starter.skmt.ExecNonQuery("delete from CUENTAA")
	Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?) ", Array As Object(Marker1.Title))
	Activity.Finish
	B4XPages.ShowPage("Cliente")
End Sub

'Evento del clic largo de la etiqueta del marcador.
Sub InfoWindowLongClick_Event (MethodName As String, Args() As Object) As Object
	Dim m As Marker = Args(0)
	Log(m.Snippet)
	Log($"Marker: ${m.Title} was long clicked"$)
	Private RES As String =  Msgbox2($"¿Quieres usar la tienda ${m.Title} como tu punto de inicio?"$, "Punto de inicio", "SI", "", "NO", Null)
	If RES = DialogResponse.POSITIVE Then
		Private t As ResultSet = Starter.skmt.ExecQuery($"select cat_cl_lat, cat_cl_long from kmt_info where cat_cl_codigo = '${m.Title}'"$)
		Do While t.NextRow
			Starter.inicioMapa = True
			Log($"${m.Title}, ${t.GetString("CAT_CL_LAT")}, ${t.GetString("CAT_CL_LONG")}"$)
			Starter.inicioLat = t.GetString("CAT_CL_LAT") + 0.000001
			Starter.inicioLon= t.GetString("CAT_CL_LONG") + 0.000001
			StartActivity(Main)
'			B4XPages.ShowPage("clientes")
			B4XPages.MainPage.clientes.caculaRutaGPS(B4XPages.MainPage.clientes.todosAVisitar, False)
			Log("A VISITAR:" & B4XPages.MainPage.clientes.todosAVisitar)
			B4XPages.MainPage.clientes.mostrarProgressDialog= True
			B4XPages.ShowPage("clientes")
		Loop
	End If
	Return Null
End Sub




'A VISITAR:(ArrayList) [[0050367281, -100.42868, 20.39391], [0050367626, -100.4087932, 20.3595788], [0050367628, -100.4117002, 20.3667028], [0050371707, -100.4071094, 20.54743853], [0050399632, -100.4015245, 20.5512081], [0050405993, -100.3929233, 20.5517732], [0050410804, -100.3992339, 20.5578613], [0050427908, -100.3868004, 20.55369944], [0050428172, -100.4030913, 20.5647105], [0050430879, -100.3921115, 20.5538267], [0050449182, -100.4015999, 20.55123943], [0050454929, -100.4131912, 20.5824743], [0050508206, -100.4012459, 20.5555874], [0050532644, -100.403956, 20.5560417], [0050532647, -100.3969627, 20.5567132], [0050534299, -100.4008553, 20.5623179], [0050542173, -100.3911378, 20.5521745], [0050545133, -100.4185117, 20.5841258], [0050545372, -100.4027919, 20.5668019], [0050546494, -100.4042279, 20.5715305], [0050550093, -100.3985692, 20.5611033], [0050555051, -100.4153573, 20.5870442], [0050561418, -100.4115342, 20.3665026], [0050572048, -100.3926747, 20.5536659], [0050573475, -100.4110183, 20.3610065], [0050579140, -100.3913611, 20.553887], [0050608099, -100.386582, 20.5529402], [0052048305, -100.3875678, 20.5551419], [0052048362, -100.4025609, 20.5588808], [0052358941, -100.4032512, 20.5511225], [0052713438, -100.4030562, 20.5659666], [0052714608, -100.40874, 20.57909], [0052833018, -100.4044418, 20.5748634], [0053579224, -100.3997321, 20.56121], [0053580677, -100.3888109, 20.5513622], [0053581646, -100.4004979, 20.5601596], [0053970391, -100.3870233, 20.553927], [0053992268, -100.4054519, 20.3539245], [0053997193, -100.4047289, 20.5522846], [0056116306, -100.3971715, 20.5577387], [0056178463, -100.3902002, 20.5518707], [0056285110, -100.3869695, 20.55236313], [0056285497, -100.4049921, 20.55511612], [0056292446, -100.4026017, 20.56614702], [0056303052, -100.4014168, 20.5534864], [SR_108541, -100.3881219, 20.55375247], [SR_108558, -100.3874667, 20.5540832], [SR_108589, -100.400523, 20.55892217], [SR_108594, -100.4022834, 20.56593209], [SR_110296, -100.392118, 20.553243]]
'A VISITAR:(ArrayList) [[0050367281, -100.42868, 20.39391], [0050367626, -100.4087932, 20.3595788], [0050367628, -100.4117002, 20.3667028], [0050371707, -100.4071094, 20.54743853], [0050399632, -100.4015245, 20.5512081], [0050405993, -100.3929233, 20.5517732], [0050410804, -100.3992339, 20.5578613], [0050427908, -100.3868004, 20.55369944], [0050428172, -100.4030913, 20.5647105], [0050430879, -100.3921115, 20.5538267], [0050449182, -100.4015999, 20.55123943], [0050454929, -100.4131912, 20.5824743], [0050508206, -100.4012459, 20.5555874], [0050532644, -100.403956, 20.5560417], [0050532647, -100.3969627, 20.5567132], [0050534299, -100.4008553, 20.5623179], [0050542173, -100.3911378, 20.5521745], [0050545133, -100.4185117, 20.5841258], [0050545372, -100.4027919, 20.5668019], [0050546494, -100.4042279, 20.5715305], [0050550093, -100.3985692, 20.5611033], [0050555051, -100.4153573, 20.5870442], [0050561418, -100.4115342, 20.3665026], [0050572048, -100.3926747, 20.5536659], [0050573475, -100.4110183, 20.3610065], [0050579140, -100.3913611, 20.553887], [0050608099, -100.386582, 20.5529402], [0052048305, -100.3875678, 20.5551419], [0052048362, -100.4025609, 20.5588808], [0052358941, -100.4032512, 20.5511225], [0052713438, -100.4030562, 20.5659666], [0052714608, -100.40874, 20.57909], [0052833018, -100.4044418, 20.5748634], [0053579224, -100.3997321, 20.56121], [0053580677, -100.3888109, 20.5513622], [0053581646, -100.4004979, 20.5601596], [0053970391, -100.3870233, 20.553927], [0053992268, -100.4054519, 20.3539245], [0053997193, -100.4047289, 20.5522846], [0056116306, -100.3971715, 20.5577387], [0056178463, -100.3902002, 20.5518707], [0056285110, -100.3869695, 20.55236313], [0056285497, -100.4049921, 20.55511612], [0056292446, -100.4026017, 20.56614702], [0056303052, -100.4014168, 20.5534864], [SR_108541, -100.3881219, 20.55375247], [SR_108558, -100.3874667, 20.5540832], [SR_108589, -100.400523, 20.55892217], [SR_108594, -100.4022834, 20.56593209], [SR_110296, -100.392118, 20.553243]]


Sub GPS_LocationChanged (Parametro As Location)
	'MARK_CEDIS.IsInitialized
'	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)
'	Else
'		GPS.Start(0, 0)
'	End If
End Sub

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

Sub B_TODOS_Click
	todos  =1
	verde = 0
	azul = 0
	rojo = 0
	MapFragment1_Ready
End Sub

Sub B_VERDE_Click
	verde = 1
	azul = 0
	rojo = 0
	todos = 0
	gmap.Clear
	MapFragment1_Ready
End Sub

Sub B_ROJO_Click
	rojo = 1
	verde = 0
	azul = 0
	todos = 0
	gmap.Clear
	MapFragment1_Ready
End Sub

Sub B_AZUL_Click
	azul = 1
	verde = 0
	rojo = 0
	todos = 0
	gmap.Clear
	MapFragment1_Ready
End Sub


Sub Activity_KeyPress (key As Int) As Boolean 'ignore
	' BACK key pressed
	If key=KeyCodes.KEYCODE_BACK Then
		
		B4XPages.ShowPage("Principal")
		Return False
		'End If
	End If
	' Returning False signals the system to handle the key
End Sub