Java – Add extra padding around CameraUpdateFactory.newLatLngBounds

Add extra padding around CameraUpdateFactory.newLatLngBounds… here is a solution to the problem.

Add extra padding around CameraUpdateFactory.newLatLngBounds

I

need to add extra padding around the markup on the map I display.

This is the code so far, but the top and bottom or west and east markers are at the edge of the screen.

 @Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
        @Override
        public void onMapLoaded() {
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            for (int i = 0; i < arrayList.size(); i++) {
                options.position(latlngs.get(i));
                options.title(arrayList.get(i).getArea().toString());
                options.snippet(arrayList.get(i).getRegion().toString());
                mMap.addMarker(options);
                builder.include(latlngs.get(i));
            }
            LatLngBounds bounds = builder.build();
            int padding = 0;
            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);

mMap.moveCamera(cameraUpdate);            }
    });

}

Here’s what I got:
What I get currently

This is what I want:
What I need
So how do I add some padding so I can see all the tags but not keep the markers close to the edge of the map? Thanks for any input.

Solution

Set the fill value > 0
Example:
int padding = 50;

Related Problems and Solutions