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

MGLMapView contentInset top is ignored for compass positioning #11068

Closed
dmdeller opened this issue Jan 26, 2018 · 6 comments
Closed

MGLMapView contentInset top is ignored for compass positioning #11068

dmdeller opened this issue Jan 26, 2018 · 6 comments
Labels
bug iOS Mapbox Maps SDK for iOS

Comments

@dmdeller
Copy link

dmdeller commented Jan 26, 2018

Platform: iOS
Mapbox SDK version: 3.7.3

Hi there,

We have been using contentInset.top to position the compass on our MGLMapView, in order to move it out of the way of some other views that we place on top of the map view. This has worked fine until recently, but was broken in Mapbox 3.7.2.

Steps to trigger behavior

Our usage looks like this: (Swift; edited for clarity)

let mapView = MGLMapView(frame: UIScreen.main.bounds, styleURL: styleURL)
mapView.zoomLevel = 12
mapView.showsUserLocation = true
mapView.setUserTrackingMode(.follow, animated: false)
mapView.contentInset = UIEdgeInsets(top: 60, left: 0, bottom: 0, right: 0)
mapView.updateConstraints()
mapView.delegate = self
view.insertSubview(mapView, at: 0)

Expected behavior

The compass should be positioned at least 60 points below the top of the MGLMapView.

Actual behavior

The compass is positioned at the top of MGLMapView. Setting contentInset makes no difference to the vertical positioning.

More info

I regression tested it on these Mapbox versions:

3.6.4: ✅ as expected
3.7.0: ✅ as expected
3.7.1: ✅ as expected
3.7.2: ❌ not as expected
3.7.3: ❌ not as expected

I think this commit may have been the breaking change: d650b91

Note that the left side of the diff references contentInset.top but the right side does not.

Question


Is this a bug, or was this change intentional? If the latter, do you have another recommendation for how to position the compass?

Thanks!

@RobertSasak
Copy link

Is there any workaround?

@julianrex
Copy link
Contributor

@dmdeller can you confirm that automaticallyAdjustsScrollViewInsets was set to NO?

@dmdeller
Copy link
Author

dmdeller commented Nov 8, 2018

@julianrex Confirmed, automaticallyAdjustsScrollViewInsets was set to NO. The problem occurs whether this is set to NO or YES. I also confirmed it still occurs under Mapbox 4.5.0.

@julianrex
Copy link
Contributor

Making a note that the ideal solution here should involve integrating the Adopt layout anchors #12147 PR.

@fabian-guerra fabian-guerra self-assigned this Nov 29, 2018
@fabian-guerra fabian-guerra removed their assignment Dec 18, 2018
@julianrex
Copy link
Contributor

Noting that this issue should be addressed by #13911 which is currently in review. /cc @chloekraw

@julianrex
Copy link
Contributor

@dmdeller #13911 has now merged and will be available in an upcoming release. This is the supported mechanism for moving "ornaments" like the compass.

I'm going to close this issue, but please reopen if necessary!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

5 participants