Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Center calculated incorrectly when resetting north with contentInset #14150

Closed

Description

@TimWatson

With contentInset set with different top and bottom values, if you reset north either by rotating the map or tapping the compass the map jumps either up or down depending on the bigger inset value

Since this only happens when userTrackingMode == .none it led me here

if (self.userTrackingMode == MGLUserTrackingModeNone)
{
self.mbglMap.easeTo(mbgl::CameraOptions()
.withBearing(direction)
.withPadding(MGLEdgeInsetsFromNSEdgeInsets(self.contentInset)),
MGLDurationFromTimeInterval(duration));
}

And since it only happens vertically that led me here

center.y = state.size.height - center.y;

I can't figure out why we have that line but I think it's causing this. The only possible explanation I could find was about macOS having a different coordinate system origin

Steps to reproduce

  1. Set userTrackingMode to .none
  2. Set mapView.contentInset = UIEdgeInsets(top: 0, left: 10, bottom: 300, right: 10)
  3. Rotate the map to anything but north
  4. Rotate the map back to north
  5. The map jumps up after you release it

Expected behavior

The map would stay as you had it before releasing it

Actual behavior

The map jumps up

Configuration

Mapbox SDK versions: ios-v4.9.0
iOS/macOS versions: iOS 12.1.4
Device/simulator models: iPhoneX
Xcode version: 10.1

Activity

  1. 1ec5 commented on Mar 19, 2019

    @1ec5
    Contributor

    I can't figure out why we have that line but I think it's causing this. The only possible explanation I could find was about macOS having a different coordinate system origin

    Unless something has changed recently, mbgl assumes an origin at the top-left, just like iOS does natively. Only macOS puts the origin at the bottom-left, but the macOS implementation of MGLMapView compensates by flipping the coordinates in Objective-C.

    // Cocoa origin is at the lower-left corner.
    pixel.y = NSHeight(self.bounds) - pixel.y;

    /ref #3574 #3583

  2. TimWatson commented on Mar 19, 2019

    @TimWatson
    Author

    Yeah that's what I found. So why are we flipping it for iOS in easeTo there?

  3. added
    iOS
    on Mar 19, 2019
  4. TimWatson commented on Apr 23, 2019

    @TimWatson
    Author

    This was fixed with the last update (4.10)

  5. julianrex commented on Apr 23, 2019

    @julianrex
    Contributor

    @TimWatson thank you for confirming!

  6. TimWatson commented on Jun 20, 2019

    @TimWatson
    Author

    This is happening again in 5.1.0

  7. added
    archived
    on Dec 18, 2019
  8. stale commented on Dec 18, 2019

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    archivediOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions