Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android maps - Markers Bounds at the center of top half of map area

I have Android Map Extension attached under actionBar.

I have couple of markers, lets say 2000.

Than I have ArrayList of selected 3 markers upon some constant condition, nevermind.

I want to zoom and move map to include this selected 3 markers at max possible zoom.

It's an easy task, from this forum I found an easy way to do it :

LatLngBounds bounds = new LatLngBounds.Builder().include(new LatLng(maxLat, maxLon)).include(new LatLng(minLat, minLon)).build();
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));

I have map perfectly zoomed at this 3 markers.

Now is hard part.

When I zoom at this markers I have layout that covers bottom half of map.

I want to archive the same situation but on upper half of map only.

Resizing map is not an option.

I've tried to enlarge my boundaries 2 times vertically but it doesn't help

Thank you for your help in advance

like image 859
Michał Rabiński Avatar asked Oct 27 '25 08:10

Michał Rabiński


1 Answers

GoogleMap.setPadding is what you need. Simply set bottom to half of the height of your map.

like image 71
MaciejGórski Avatar answered Oct 29 '25 07:10

MaciejGórski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!