Mapbox-gl-native: Android: Adjust map compass/logo to insets when using translucent status/navigation bar

Created on 12 Jan 2017  路  5Comments  路  Source: mapbox/mapbox-gl-native

I couldn't find a method to do this.
I want the map to draw under the status and navigation bar, but the rest of je views like compass and logo should receive extra insets so these are on the right position.

Right now I'm using ViewCompat.setOnApplyWindowInsetsListener() to get the insets and add the systemWindowInsets to the margins in uiSettings (like LogoMargins) that already exist. But I think it would be better if the map could do this.

Android support

Most helpful comment

@kevinvanmierlo have you looked into using Mapbox#setPadding? This will add padding to all widgets at once and reposition the focal point of the map. This should solve the issue you are having. Related tot this topic, we have been thinking about adding support for something as coordinatorlayout to allow to animate the overlain items.

All 5 comments

@kevinvanmierlo thank you for reaching out! you can adjust the position of the compass with Mapbox.getUiSettings().setCompassMargins(int left, int top, int right, int bottom). We have similar methods for Attribution and the logo. Feel free to reach out if you have any other questions. Closing as resolved.

@tobrun I know I can do that, but than I have to do that to logo, compass and attribution. It would be easier for everyone who wants to use translucent status and/or navigation bar if mapbox would support this by setting insets or something on every item in the map (so maybe one method to set the extra margins for logo, compass and attribution). Or maybe mapbox could automatically detect the extra insets and adjust accordingly.

I'm just making suggestions, let me know what you think

@kevinvanmierlo have you looked into using Mapbox#setPadding? This will add padding to all widgets at once and reposition the focal point of the map. This should solve the issue you are having. Related tot this topic, we have been thinking about adding support for something as coordinatorlayout to allow to animate the overlain items.

@tobrun That was indeed what I was looking for! Can't believe I missed that. Thanks!
That would be awesome. Haven't used coordinatorlayout a lot though so I can't really say anything about it.

Was this page helpful?
0 / 5 - 0 ratings