Android: Setting Zoom Level in Google Maps to include all Marker points

后端 未结 3 759
野性不改
野性不改 2021-01-30 05:07

I am trying to set zoom level for Maps in android such that it includes all the points in my list. I am using following code.

int minLatitude = Integer.MAX_VALU         


        
3条回答
  •  温柔的废话
    2021-01-30 05:44

    Yet another approach with Android Map API v2:

    private void fixZoom() {
        List points = route.getPoints(); // route is instance of PolylineOptions 
    
        LatLngBounds.Builder bc = new LatLngBounds.Builder();
    
        for (LatLng item : points) {
            bc.include(item);
        }
    
        map.moveCamera(CameraUpdateFactory.newLatLngBounds(bc.build(), 50));
    }
    

提交回复
热议问题