-
-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix double padding on camera when setting bounds #3354
Conversation
ios/RNMBX/RNMBXCamera.swift
Outdated
if let _minNS = minZoomLevel, let _min = CGFloat(exactly: _minNS), let _zoom = zoom, _zoom < _min { | ||
zoom = _min | ||
} | ||
if let _maxNS = maxZoomLevel, let _max = CGFloat(exactly: _maxNS), let _zoom = zoom, _zoom < _max { | ||
zoom = _max | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This clamping logic doesn't actually have an effect - the map automatically restricts according to the min/max zoom settings.
@mfazekas I left a couple of comments on the code. On another note, there's some idiosyncratic behavior depending on the combination of padding and min/max zoom limits. This exists in the native SDK, so it's probably not something we need to deal with here, but I wanted to check. Basically, with no The video should help clarify. Thoughts? zoom-limits.mov |
@naftalibeder ci needs a fix here |
@naftalibeder pls merge the PR as CI was broken on main |
CI error: | Error: src/examples/V10/CameraAnimation.tsx(1,43): error TS6133: 'color' is declared but its value is never read. |
This fixes a configuration like
producing the warning
due to the center and zoom already including the calculated padding, and then the padding being reapplied in the camera configuration.
I believe this has always been an issue, but it's become problematic in Mapbox 11, as the internal camera now fails to move if total padding exceeds the map size.
I also went ahead and added a condition that scales down the padding so it doesn't ever exceed the map size. What do you think about this? My thinking is: when working with the native Mapbox SDK, you can easily check e.g:
but it's not as easy in JavaScript to get the current map height, so that kind of check is more brittle.
Ideally, this sort of overflow would be compensated for in the Mapbox SDK, but I'm not sure if I would consider it a bug vs. just a design choice I don't like. :)