Sub MapFragment1_Ready
map = MapFragment1.GetMap
map.MyLocationEnabled = True
Dim googlemapsextra As GoogleMapsExtras
''this is where the marker locations are being added to be used later below to calculate the bounds so that the map can center all the markers added.
Dim LatLngBoundsBuilder1 As LatLngBoundsBuilder
LatLngBoundsBuilder1.Initialize
markers.Initialize
If common.objectlist.Size > 0 Then
For i = 0 To common.objectlist.Size - 1
Dim data As NearByData
Log("objectlist: " & i & " " & common.objectlist.Get(i))
data.Initialize
data = common.objectlist.Get(i)
LogColor("location added: " & data.Lat & " " & data.Lon, Colors.Red)
Dim m1 As Marker = map.AddMarker(data.Lat, data.Lon, data.Bus_Number)
m1.Snippet = data.Title & CRLF & "Bus Stop# " & data.Tag
''adding markers to the LatLngBoundsBuilder
LatLngBoundsBuilder1.Include(m1.Position)
markers.Put(m1, m1)
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, clv.AsView.Width, 75dip)
clv.Add(p, data)
Next
Dim InfoWindowAdapter1 As InfoWindowAdapter
InfoWindowAdapter1.Initialize("InfoWindowAdapter1")
googlemapsextra.SetInfoWindowAdapter(map, InfoWindowAdapter1)
infowindow.Initialize("")
infowindow.SetLayoutAnimated(0,0,0,230dip,120dip)
infowindow.LoadLayout("InfoWindow")
''hackish way to add custom infowindow with custom size
pnlmapfragment.AddView(infowindow, 0, 0, 230dip, 120dip)
infowindow.RemoveView
Dim MarkerBounds As LatLngBounds=LatLngBoundsBuilder1.Build
Dim camupdate As CameraUpdate
Dim camfactory As CameraUpdateFactory
camupdate = camfactory.NewLatLngBounds2(MarkerBounds, 100%x, pnlmapfragment.Height, 128)
googlemapsextra.AnimateCamera(map, camupdate)
End If
End Sub