Skip to content

CameraUpdate.newLatLngBounds() applies incorrect padding on iOS #1034

Closed
@easazade

Description

@easazade

First of all a thank you for all the effort everyone is putting on this library. 👍

Here is what I'm trying to do:

create a new CameraUpdate object using CameraUpdate.newLatLngBounds(latlng,...) with some padding then use controller.animateCamera(cameraUpdate) to update the mapbox's camera position. below is the example code

final padding  = EdgeInsets.only(top: 0, bottom: 0, left: 0, right: 100);

final cameraBounds = CameraUpdate.newLatLngBounds(
  latLngBounds,
  left: padding.left,
  right: padding.right,
  top: padding.top,
  bottom: padding.bottom,
);

await mapController.animateCamera(cameraBounds);

Here is the problem:

the left and right padding are not being applied as the arguments assigned for them. what is happening is that left and right padding are summed up and then divided by 2 the result will be set for both left and right padding

for example if we set right padding to 100 and left padding to 0 when padding is being applied on iOS instead of applying 100 padding to the right, it is setting left padding to 50 and right padding to 50.

for example if we swap the padding in the example code above with below padding objects the result will not change on iOS.
since in all of the the sum of left & right padding is 100.

final padding  = EdgeInsets.only(top: 0, bottom: 0, left: 100, right: 0);
final padding  = EdgeInsets.only(top: 0, bottom: 0, left: 30, right: 70);
final padding  = EdgeInsets.only(top: 0, bottom: 0, left: 10, right: 90);
final padding  = EdgeInsets.only(top: 0, bottom: 0, left: 0, right: 100);

NOTE that same problem exists for top and bottom paddings.

Steps to reproduce on example app

to reproduce this issue in the example app go to animate_camera.dart and change the value of top and bottom padding on line 96. and click on newLatLngBounds button on Camera control, animated screen. you see that padding does not change

I have tested this on iPhone 7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions