Terradrones
Active Member
Hi All
I have code that reads in the coordinates of my Benchmarks (Reference Points), gets converted to Lats and Longs and then plotted on the Map. Once the file has been read, the program zooms in to the center of the points.
I have 3 types of coordinate files: Local, Site and Global. If 1 of these Files has no data, then I would like to zoom in on the location of the Device. I have looked everywhere, but cannot find a solution.
I have code that reads in the coordinates of my Benchmarks (Reference Points), gets converted to Lats and Longs and then plotted on the Map. Once the file has been read, the program zooms in to the center of the points.
I have 3 types of coordinate files: Local, Site and Global. If 1 of these Files has no data, then I would like to zoom in on the location of the Device. I have looked everywhere, but cannot find a solution.
B4X:
[/
Sub PlotPoints(A As Int)
Dim AveY, AveX As Double
Dim cp As CameraPosition
Private co As CircleOptions
co.Initialize
Try
gmap.Clear
If CGlobals.CoordCode=1 Then
'Site Coords
Dim rs As ResultSet = CGlobals.sql1.ExecQuery("SELECT Name, East, North, Elevation, Description FROM SCoords ORDER BY Name ASC")
else if CGlobals.CoordCode=2 Then
'Global Coords
Dim rs As ResultSet = CGlobals.sql1.ExecQuery("SELECT Name, East, North, Elevation, Description FROM GCoords ORDER BY Name ASC")
Else
'Job Coords
Dim rs As ResultSet = CGlobals.sql1.ExecQuery("SELECT Name, East, North, Elevation, Description FROM Coords ORDER BY Name ASC")
End If
i=0: AveY=0: AveX=0
Do While rs.NextRow
Dim row(5) As Object
row(0) = rs.GetString("Name")
row(1) = NumberFormat2(rs.GetDouble("East"),1,3,3,False)
row(2) = NumberFormat2(rs.GetDouble("North"),1,3,3,False)
'row(3) = NumberFormat2(rs.GetDouble("Elevation"),1,3,3,False)
Engine.Hart94_YX(row(1),row(2),19)
co.StrokeWidth(2)
co.Center2(Engine.Lat,Engine.Lon).Radius(Radius.SelectedItem).FillColor(Colors.White).StrokeColor(Colors.DarkGray)
gmapextra.AddCircle(gmap,co)
i=i+1
AveY=AveY+row(1)
AveX=AveX+row(2)
Loop
rs.Close
If (AveY<>0 Or AveX<>0) And A=0 Then
'Zoom in to center of points
AveY=AveY/i
AveX=AveX/i
Engine.Hart94_YX(AveY,AveX,19)
cp.Initialize(Engine.Lat,Engine.Lon, 10)
gmap.MoveCamera(cp)
Else
'No data has been found, so zoom in to location of Device....DOES NOT WORK
cp.Initialize(cp.Target.Latitude, cp.Target.Longitude, 10)
gmap.MoveCamera(cp)
End If
Catch
Log(LastException)
End Try
End Sub
Sub Radius_SelectedIndexChanged (Index As Int)
PlotPoints(1)
End Sub
]
Any advise please?
Thanks
Michael