Google Maps v2 Set Zoom Level

前端 未结 5 851
遇见更好的自我
遇见更好的自我 2021-02-12 16:46

When I launch Google maps in Android, it shows the whole world. What do i need to change so as to set the zoom to the marker? Here are the codes. Thanks

                 


        
5条回答
  •  面向向阳花
    2021-02-12 17:23

    If you have a Place (or bounds), you could zoom to it. E.g. zoom to specific country, city or address with .newLatLngBounds() method:

    map.animateCamera(CameraUpdateFactory.newLatLngBounds(place.getViewport(), 10)); // 10 is padding
    

    Zoom level will be selected automatically. It works perfectly with location search.

提交回复
热议问题