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.
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!
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With