Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Map Bounds with different padding

I want to know if ther is any way of set different padding from each site of the Device for Google maps bounds.

Because I have an mpview witch match the whole activity, but I have a MapOverlay (some Text inside a linerar Layout with non transulent background) on the bottom 1/3 off the screen.

And now i want to zoom in by using map bounds. But it should have more padding from the bottom so it didn't get behind my mapOverlay.

I use this code with the padding of 120.

final com.google.android.gms.maps.model.LatLngBounds.Builder bounds = new LatLngBounds.Builder();
bounds.include(pref.getSavedLatLng());
bounds.include(currentLatLng);
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds.build(), 120));

Is there any way of setting different paddings, or other solution for this problem?

Thank you for helping and sorry for my english.

like image 527
MEX Avatar asked Nov 27 '13 19:11

MEX


1 Answers

This is an older question and maybe the asker found the solution but here it is for anyone who faces same problem in future. Set the individual padding using

googleMap.setPadding(left, top, right, bottom)

and then use

googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds.build(), 0))

Don't forget to set the paddings back to 0 (or whatever they were before) after you are done. Because unlike newLatLngBounds(), the paddings set by setPadding() are permanent.

like image 188
VipulKumar Avatar answered Nov 02 '22 05:11

VipulKumar