mapbox / mapbox-gl-native-ios

Interactive, thoroughly customizable maps for iOS powered by vector tiles and OpenGL
https://www.mapbox.com/mobile/
Other
210 stars 122 forks source link

Uncoordinated location annotation and map movement when setting zoom level with non-center anchor point #402

Open fweez opened 4 years ago

fweez commented 4 years ago

Our app has buttons to increase or decrease the zoom level of the map. When using those while the map's user location anchor point is not in the middle of the map, the map and the user location don't coordinate their movement. The map animates to its new zoom level bringing the user location to the middle of the map view while the user location annotation remains at its original screen position, then there is a separate animation as the map translates to put the user location annotation in the right place.

Screen Recording 2020-08-31 at 2 04 49 PM

Steps to reproduce

  1. Add a mapViewUserLocationAnchorPoint: delegate method which sets a user location off the center of the map (for instance, CGPointMake(mapView.bounds.size.width * 0.5, mapView.bounds.size.height * 0.8);)
  2. Zoom the map programmaticaly ([self.mapView setZoomLevel:self.mapView.zoomLevel - 1 animated:false];, or animated:true, or self.mapView.zoomLevel -= 1;)

Expected behavior

Map zooms such that the user location annotation stays on the correct point on the map, and the user location doesn't move off the anchor point.

Actual behavior

Map zooms putting the user location in the center of the view, then after the zoom completes the map translates to put the user location under the user location annotation; while all of those animations happen, the user location annotation does not move from its screen position.

Configuration

Mapbox SDK versions: 5.3, 6.0, 6.1 iOS/macOS versions: iOS 13.6, 14 beta Device/simulator models: Any -- tested on iPhone 11, iPhone 7 hardware, and a variety of simulators Xcode version: 11.6, 12 beta

fweez commented 4 years ago

Here's a diff against the ios-v6.1.0 tag to demonstrate the issue in the Mapbox GL demo app:

demo.diff.zip