Android Question Google Maps - Center Map

Discussion in 'Android Questions' started by daniedb, Jun 6, 2015.

  1. daniedb

    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can set the visible region with GoogleMapsExtra library. You will need to go over the markers and calculate the desired region.
     
  3. daniedb

    daniedb Active Member Licensed User

    Thanks Erel, will have a look into that...appreciate
     
  4. eurojam

    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):
    Code:
    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
     
  5. daniedb

    daniedb Active Member Licensed User

    Thanks Stefan, appreciate. Will try this
     
Loading...