Android Question Google Maps - Center Map

daniedb

Active Member
Licensed User
Hi Guys
Struggle again with some Google Maps info.
How do I show (Center) the map that all available markers show, currently it zoom to the last Marker. They might be spread, so I need them show them all to show on the map, with the best ":zoom"


Thanks
D
 

eurojam

Well-Known Member
Licensed User
I would put all the lat and lon coordinates in 2 lists (lat-list, lon-list) and then sort the lists. Then you have the south-west (lowest lat and lowest lon) and northeast corners (highest lat...) of your marker-bounds. After that you can use the CameraUpdateFactory of googlemapextras, something like this (not tested):
B4X:
   Dim CameraUpdateFactory1 As CameraUpdateFactory
   Dim CameraUpdate1 As CameraUpdate
   Dim llbounds As LatLngBounds
   Dim sw, ne As LatLng 'your southwest and northeast corners
  
   llbounds.Initialize(sw, ne)
   CameraUpdate1=CameraUpdateFactory1.NewLatLngBounds(llbounds,10)
   GoogleMapsExtras1.MoveCamera(gmap, CameraUpdate1)
Best regards
stefan
 
Top