Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining a CameraUpdate with LatLngBounds with different padding values

Is there a function that allows specifying default padding values for different edges of the MapFragment, i.e. similar to

CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds, int padding)

which already exists, but instead something like

CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds, int paddingTop, int paddingLeft, int paddingBottom, int paddingRight)?

Why I need this: In my MapFragment I have a half transparent layer on top. Therefore I need a wider padding at the top than at the bottom.

enter image description here

I found this similar question: Offseting the center of the MapFragment for an animation moving both the target lat/lng and the zoom level. However, getting the projection and scrolling by X pixels is not enough in my case, because I don't only want to scroll (pan). I use a CameraUpdate with newLatLngBounds(bounds, padding), which is supposed to both zoom and pan. So I have a different projection before the camera update.

I hope I made the question clear!

like image 331
ercan Avatar asked Feb 23 '14 15:02

ercan


1 Answers

This is an example of set padding to map...

Sets padding on the map.

This method allows you to define a visible region on the map, to signal to the map that portions of the map around the edges may be obscured, by setting padding on each of the four edges of the map. Map functions will be adapted to the padding. For example, the zoom controls, compass, copyright notices and Google logo will be moved to fit inside the defined region, camera movements will be relative to the center of the visible region, etc.

*the size is in pixels

GoogleMap.setPadding(     10,      20,      20,     50);

    all are Int                       left,        top,       right,  bottom

from @MaciejGorsky, here is the documentation...

https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap?hl=pl#setPadding(int, int, int, int)

like image 135
DarckBlezzer Avatar answered Oct 14 '22 16:10

DarckBlezzer