-
Notifications
You must be signed in to change notification settings - Fork 160
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
Setting camera bounds with padding fails [v11] #2134
Comments
@naftalibeder this should be fixed in 11.2 may you please verify and close the issue if it was resolved |
Also please migrate to use the following method https://docs.mapbox.com/ios/maps/api/11.2.0/documentation/mapboxmaps/mapboxmap/camera(for:camera:coordinatespadding:maxzoom:offset:)/ |
hi @aleksproger I'm struggling slightly with this one myself. I understand the |
Hi, @amzada if I understand correctly you may do smth like this let coordinateBounds = mapView.mapboxMap.coordinateBounds(for: CGRect())
let boundingPolygonCameraOptions = try mapView.mapboxMap.camera(
for: [cooridnateBounds.northwest, cooridnateBounds.southeast],
camera: initialCameraOptions,
coordinatesPadding: coordinatesPadding,
maxZoom: nil,
offset: nil
) |
@aleksproger I would still need to pass in my list of coordinates somehow. So |
hi @aleksproger was wondering if you had a chance to look at my comment above? |
@amzada may you please provide a snippet of what methods you used before to achieve the desired result? |
@aleksproger I was able to get an 'ok' solution in the past using the previous |
hi @aleksproger would just like to check on this one last time. Anything from your side please? |
@aleksproger My apologies for the delay on testing. I just tried with the SDK version camera = try map.mapboxMap.camera(
for: bounds,
camera: .init(
bearing: 0,
pitch: 0
),
coordinatesPadding: padding,
maxZoom: nil,
offset: nil
) It has the exact same result as in my original description. Do you have any more information about this? |
I'm not sure what my previous test was doing, but the new method is actually working in v11! My mistake. Note that the deprecated function is not working in v11, but that's not really a concern. |
Environment
Observed behavior and steps to reproduce
When setting the camera to a coordinate bounds with padding, the camera does not zoom out to encompass the provided bounds.
To reproduce, run this example with Mapbox >= 11.0.0 and click the
Change
button repeatedly:CameraAnimationExample.swift
Expected behavior
On repeat click, the camera should alternatively ease between a center coordinate and a slightly zoomed out bounds, both bottom-padded.
Actual behavior
The camera moves laterally to the approximate bounding box, but the zoom does not change. The following seemingly contradictory data prints to the console:
Notes / preliminary analysis
try camera(for:camera:coordinatesPadding:maxZoom:offset:)
has the same issue, but it throws instead of quietly logging to the console.>=353
: Zoom does not change, as shown in the v11 video.=352
: Suddenly zooms way out to bound around a very large area.<=351
: As padding gets closer to zero, zoom increases until eventually settles at the correct value when padding is 0.Additional links and references
The above example behaves correctly on v10:
v10.mov
but fails on v11:
v11.mov
The text was updated successfully, but these errors were encountered: