I see it is possible to use OSMDoid to create a map view and calculate a bounding box for a list of coordinates. Is there functionality in the google maps library in B4A and b4i to calculate a bounding box and move the camera position include all the points in the map fragment view.
Below returns the center of the box using OSMDroid:
Maybe the solution is to use the point returned by osmdroid in google maps? But I would prefer to stick to one library and fit the map to the bounding box.
Regards
Below returns the center of the box using OSMDroid:
B4X:
Sub createBoundingBox As GeoPoint
Dim m As Map
Dim data As JSONParser
data.Initialize(coords)
Dim datacoords As Map = data.NextObject
m = datacoords.get("geometry")
Dim l As List
l = m.Get("coordinates")
Dim points As List
points = l.Get(0)
' Dim points As Map = data1.Get("coordinates")
Dim lats As List
lats.Initialize
Dim lng As List
lng.Initialize
For i= 0 To points.Size-1
Dim tmparr As List = points.Get(i)
lats.Add(tmparr.Get(0))
lng.Add(tmparr.Get(1))
Next
' Log(lats)
' Log(lng)
'get min and max lat
Dim minlat As Double = 999999
Dim maxlat As Double = -999999
For i =0 To lats.Size -1
If lats.Get(i) < minlat Then
minlat = lats.Get(i)
End If
If lats.Get(i) > maxlat Then
maxlat = lats.Get(i)
End If
Next
Dim minlng As Double = 999999
Dim maxlng As Double = -999999
For i =0 To lng.Size -1
If lng.Get(i) < minlng Then
minlng = lng.Get(i)
End If
If lng.Get(i) > maxlng Then
maxlng = lng.Get(i)
End If
Next
Log(minlng)
Log(maxlng)
box.Initialize(minlat,minlng,maxlat,maxlng)
Return box.Center
End Sub
Maybe the solution is to use the point returned by osmdroid in google maps? But I would prefer to stick to one library and fit the map to the bounding box.
Regards