Mapbox-gl-native: Updating and restoring camera pitch causes a shift north

Created on 8 Apr 2019  路  5Comments  路  Source: mapbox/mapbox-gl-native

When changing the pitch of the current camera to a different angle, and changing it back to the original angle, the map has moved from its original position. This does NOT happen when doing the same thing with a two finger pan.

From what I suspect it may have to do with the edge padding, caused by the difference between using CameraOptions' anchor and center properties. The pan method sets the anchor to the center coordinate, whereas in my programmatic camera change I can not access this property and use the current camera's center.

Steps to reproduce

  1. Ensure a 0 pitch of the current map camera
  2. Programmatically obtain the current map's camera, set the pitch to an angle of 45 degrees, and call setCamera: on the map with the newly created camera.
  3. Programmatically change the map's camera back to its original pitch angle of 0 degrees.

Expected behavior

The map looks identical at step 1 and 3.

Actual behavior

The map has moved substantially up north.

Configuration

Mapbox SDK versions: 4.3
iOS/macOS versions: iOS 12.1.1
Device/simulator models: iPad Mini
Xcode version: 10.1

bug iOS

All 5 comments

This might be related to #14150

@friedbunny is there anything I could do to help resolve this issue? Would a sample project help (I'm looking at the 'needs reproduction' label)?

@datwelk a reproduction sample project would be most welcome!

@julianrex here you go: https://github.com/datwelk/MapboxPerspectiveBug

It seems to only occur when edgePadding is provided when updating the map's camera. Perhaps I'm misinterpreting the meaning of the edge padding? See this line

@datwelk thanks.
Fix for this is part of PR #14664. I used this patch with iOS demo to reproduce/verify it.

Was this page helpful?
0 / 5 - 0 ratings