Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add extra padding around CameraUpdateFactory.newLatLngBounds

I need to add extra padding around the markers on the map that I show.

Here is the code so far but the top and bottom or west and east markers are on 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 is what I get: What I get currently

This is what I want: What I need So how can I add some padding so that I can see all the markers but not have the markers butted against the edge of the map? Thanks for any input.

like image 477
timv Avatar asked Dec 10 '22 14:12

timv


1 Answers

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

like image 154
Shweta Nandha Avatar answered Dec 13 '22 02:12

Shweta Nandha