Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
easazade opened this issue May 6, 2022 · 5 comments
Closed

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

easazade opened this issue May 6, 2022 · 5 comments
Labels

Comments

@easazade
Copy link

easazade commented May 6, 2022

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

@easazade
Copy link
Author

easazade commented May 6, 2022

#382 is the pull request that added separate values for padding.

@easazade
Copy link
Author

easazade commented May 9, 2022

I think this mapbox/mapbox-gl-native-ios#198 on mapbox-gl-native-ios is also related

@easazade
Copy link
Author

easazade commented May 10, 2022

Please review #1039
fixe the bug

@stale
Copy link

stale bot commented Jul 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 9, 2022
@stale stale bot closed this as completed Jul 16, 2022
@paulVulog
Copy link

Hi, I guess I am facing the same issue on my side :
It only occurs on iOS.
From a high level point of view, here is what I suppose :

It looks like the CameraUpdate.newLatLngBounds(EdgeInsets) do not take into account the provided EdgeInset (keeping the current edgeInset in place) .
Whereas the MapboxMapController.updateContentInsets(EdgeInsets) function is working as expected.

Any Update on this ?


My workaround for now will be to set the EdgeIndset just before calling the newLatLngBounds method for iOS only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants