Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Narrow but high viewport does not fit into area constrained by map.setPadding #240

Closed
samiede opened this issue Jul 3, 2019 · 3 comments
Labels

Comments

@samiede
Copy link

samiede commented Jul 3, 2019

In our app, we show a screen with a map on it, which has a bottom overlay. This overlay can be dragged over the screen and snaps to certain positions. When the overlay is pulled all the way down, the map has a relatively small bottom padding that allows the drag handler to be visible. Using this small padding of 120, the bounds of the viewport are correctly centered and the whole viewport is visible.
If we now drag the panel up, we set a higher bottom padding of the 50% of the map height and expect the viewport to still be visible in the now smaller area of the map, e.g. by zooming out.
What actually happens is that the whole viewport is only shifted up slightly, not even in a way that the center would be correct, and no zooming out happens.

Steps to reproduce

  1. set low bottom padding
  2. move camera
  3. set high bottom padding
  4. move camera

Expected behavior

The viewport is visible in the now smaller area of the map.

Actual behavior

The viewport is shifted up slightly.

Screenshot_1562170131
In the bottom position, padding is applied correctly and the whole viewport is visible

Screenshot_1562170135
With the panel in the center position, the viewport is not shown correctly

We use the following code to set the bottom padding:

internal fun setViewportPadding(left: Int, top: Int, right: Int, bottom: Int) {
    mapReady {
        val bounds = this.map?.projection?.getVisibleRegion(false)?.latLngBounds
        if (bounds != null) {
            val cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 0)
            this.map?.setPadding(left, top, right, bottom)
            this.map?.animateCamera(cameraUpdate, 500)
        }
    }
}

Configuration

Android versions: 8/9
Device models: Pixel2/3, One Plus 5
Mapbox SDK versions: 8.0.1

@tobrun
Copy link
Member

tobrun commented Jul 9, 2019

@samiede thank you for reaching out and using our products. Haven't had the time to reproduce your issue but here is an example of the same user experience that you are trying to achieve.

@cmahopper
Copy link

cmahopper commented Aug 8, 2019

@tobrun We're experiencing the same problem. We want to zoom out and display a user's route in full, taking into account if a BottomSheet is open. However, when the route is tall and narrow, only the middle part of the route is shown, like in the second image above.
We're using Mapbox SDK 8.2.1

@chloekraw chloekraw transferred this issue from mapbox/mapbox-gl-native Mar 6, 2020
@stale stale bot added the archived label Sep 6, 2020
@stale
Copy link

stale bot commented Sep 7, 2020

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Sep 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants