mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

camera.fly with edge insets does not work as expected

Open richardpineo opened this issue 3 years ago • 4 comments

Environment

  • Xcode version: 13.2.1
  • iOS version: all, but simulator iOS 15.2 exhibits it
  • Devices affected: ipad
  • Maps SDK Version: 10.2.0

Observed behavior and steps to reproduce

If you try to fly to a location or geometry with a top edge inset that is sufficiently larger than the bottom edge inset, then the animation will jerk at the end and the map will have a weird margin at the top of the view.

This code added to the viewDidLoad() method in the BasicMapExample will show the bug:

mapView.mapboxMap.onEvery(.mapLoaded) { _ in
	let options = CameraOptions(center: .init(latitude: 40, longitude: 40), padding: .init(top: 250, left: 30, bottom: 50, right: 33))
	self.mapView.camera.fly(to: options, duration: 1 )
}

Expected behavior

The map should fly to the position smoothly and not have a strange margin at the top. If you change the top edge inset to 50 then it will work as expected.

Notes / preliminary analysis

No idea why this doesn't work but it interferes with the padding that we would like to apply to our application.

Additional links and references

https://user-images.githubusercontent.com/8593979/148146674-2c645551-bcf2-4107-9920-fb15cb3b4edf.mov

richardpineo avatar Jan 05 '22 01:01 richardpineo

@richardpineo thank you for reporting this behavior. I am able to reproduce it on v10.2.0 and will investigate the cause.

ZiZasaurus avatar Jan 05 '22 19:01 ZiZasaurus

Any update on this? It also occurs if you provide padding on the left-edge of the view and it's really jarring. We'd like to be able to set the padding for the camera and have it update smoothly.

Is there a workaround that can be applied?

richardpineo avatar Mar 09 '22 21:03 richardpineo

Try mapView.camera.ease(to: newCamera, duration: 5.0) { [weak self] (_) in } instead of .fly.

petermulsh avatar Apr 23 '22 14:04 petermulsh

I'm experiencing the same issue. Any updates?

dandyweng avatar Sep 12 '23 05:09 dandyweng