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

CamerdaUpdateFactory.newLatLngBounds Padding Issue #9218

Closed
JustSayBien opened this issue Jun 8, 2017 · 1 comment
Closed

CamerdaUpdateFactory.newLatLngBounds Padding Issue #9218

JustSayBien opened this issue Jun 8, 2017 · 1 comment
Labels
Android Mapbox Maps SDK for Android

Comments

@JustSayBien
Copy link

Platform: Android
Mapbox SDK version: 5.0.2

Steps to trigger behavior

  1. set an asymmetric mapPadding to the Map, e.g. mapBoxMap.setPadding(400, 0, 0, 0)
  2. update the camera with a CameraBoundsUpdate, e.g. mapBoxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 30))

Expected behavior

The map should move the camera to the provided bounds (respecting the map-padding) so that the bounds are completely visible.

Actual behavior

The bounds are not completely visible. The map center is displaced too much on the x-axis while it has the right zoom-level to show the bounds.

Note

We were able to fix this by writing our own CameraBoundsUpdate with following changes in getCameraPosition(MapboxMap mapboxMap):

        // Calculate the center point
        //PointF paddedNEPixel = new PointF(nePixel.x + padding.right / minScale, nePixel.y + padding.top / minScale);
        //PointF paddedSWPixel = new PointF(swPixel.x - padding.left / minScale, swPixel.y - padding.bottom / minScale);
        PointF paddedNEPixel = new PointF(nePixel.x, nePixel.y);
        PointF paddedSWPixel = new PointF(swPixel.x, swPixel.y);
@kkaefer kkaefer added the Android Mapbox Maps SDK for Android label Jun 8, 2017
@tobrun
Copy link
Member

tobrun commented Jun 8, 2017

With the upcoming 5.1.0 release we have changed the way we handle LatLngBounds in #8765. Feel free to test out the SNAPSHOT or any of the beta releases. More information on those here.

For reference: no map or latlngbounds padding:
0padding

Map padding, no latlngbounds padding:
device-2017-06-08-120240

Map and latlngbounds padding:
device-2017-06-08-120342

Thank you for reaching out but closing this as resolved.

@tobrun tobrun closed this as completed Jun 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

3 participants