11

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!

Community
  • 1
  • 1
ercan
  • 1,639
  • 1
  • 20
  • 34
  • 7
    Have you tried using [`GoogleMap.setPadding`](https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap?hl=pl#setPadding%28int,%20int,%20int,%20int%29)? – MaciejGórski Feb 24 '14 at 04:42
  • 4
    That's it, thanks!! I should have read the documentation more carefully ;) Please post as answer so I can accept it... – ercan Feb 24 '14 at 10:43

1 Answers1

8

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)

DarckBlezzer
  • 4,578
  • 1
  • 41
  • 51