#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#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
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 MapFragment1 As MapFragment
Private gmap As GoogleMap
Dim M1 As Marker
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("mapa")
End Sub
Sub Activity_Resume
Try
Wait For gmap_Ready
gmap = MapFragment1.GetMap
Dim latitud As Double
Dim longitud As Double
Dim registro As ResultSet=Main.SQL1.ExecQuery("Select id, latitud, longitud from coordenadas")
Do While registro.NextRow
latitud= registro.GetString("latitud")
longitud=registro.GetString("longitud")
M1 = gmap.AddMarker(latitud, longitud,"BACHE")
Loop
registro.Close
Catch
MsgboxAsync("Se produjo el error : "& LastException.Message,"Error")
End Try
End Sub
Sub MapFragment1_Ready
gmap = MapFragment1.GetMap
gmap.MyLocationEnabled = True
End Sub
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#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
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 MapFragment1 As MapFragment
Private gmap As GoogleMap
Dim M1 As Marker
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("mapa")
End Sub
Sub Activity_Resume
Dim cp As CameraPosition ' <--- añadido
Try
Wait For gmap_Ready
gmap = MapFragment1.GetMap
Dim latitud As Double
Dim longitud As Double
Dim registro As ResultSet=Main.SQL1.ExecQuery("Select id, latitud, longitud from coordenadas")
Do While registro.NextRow
latitud= registro.GetString("latitud")
longitud=registro.GetString("longitud")
M1 = gmap.AddMarker(latitud, longitud,"BACHE")
Loop
registro.Close
' Y estas dos lineas'
cp.Initialize(latitud, longitud,15)
gmap.AnimateCamera(cp)
Catch
MsgboxAsync("Se produjo el error : "& LastException.Message,"Error")
End Try
End Sub
Sub MapFragment1_Ready
gmap = MapFragment1.GetMap
gmap.MyLocationEnabled = True
End Sub
Gracias por responder.Me parece que te flata "mover la cámara" a la zona del mapa donsde tienes las marcas. Prueba con esto:
B4X:#Region Activity Attributes #FullScreen: False #IncludeTitle: True #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 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 MapFragment1 As MapFragment Private gmap As GoogleMap Dim M1 As Marker End Sub Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: Activity.LoadLayout("mapa") End Sub Sub Activity_Resume Dim cp As CameraPosition ' <--- añadido Try Wait For gmap_Ready gmap = MapFragment1.GetMap Dim latitud As Double Dim longitud As Double Dim registro As ResultSet=Main.SQL1.ExecQuery("Select id, latitud, longitud from coordenadas") Do While registro.NextRow latitud= registro.GetString("latitud") longitud=registro.GetString("longitud") M1 = gmap.AddMarker(latitud, longitud,"BACHE") Loop registro.Close ' Y estas dos lineas' cp.Initialize(latitud, longitud,15) gmap.AnimateCamera(cp) Catch MsgboxAsync("Se produjo el error : "& LastException.Message,"Error") End Try End Sub Sub MapFragment1_Ready gmap = MapFragment1.GetMap gmap.MyLocationEnabled = True End Sub