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

setVisibleCoordinateBounds:edgePadding:animated: not working for iPhone 6 #1817

Closed
picciano opened this issue Jul 1, 2015 · 9 comments
Closed
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS

Comments

@picciano
Copy link

picciano commented Jul 1, 2015

Okay, here's a weird one. I am using setVisibleCoordinateBoundsedgePaddinganimated: to zoom the map into a route. On iPhone 5S, this work perfectly. However, on the iPhone 6 the map is centered way off into the mountains. I've double checked that I am passing in the same coordinates. The only difference (from what I can tell) is that the map is a bit wider on the iPhone 6 screen.

Same code base, running in Simulator. Any ideas?

iPhone 5S Results
ios simulator screen shot jul 1 2015 12 54 24 pm

iPhone 6 Results
ios simulator screen shot jul 1 2015 12 51 19 pm

iPhone 5S Values
screen shot 2015-07-01 at 12 53 43 pm

iPhone 6 Values
screen shot 2015-07-01 at 12 51 08 pm

@1ec5
Copy link
Contributor

1ec5 commented Jul 1, 2015

Huh, I tested this functionality on an iPhone 6, actually. Some questions for you:

  1. Does the MGLMapView’s frame match your expectations?
  2. Do you see the same behavior with and without animation?
  3. Are you doing anything else that would affect the viewport (like zooming or rotating), at any time from the call to -setVisibleCoordinateBounds:edgePadding:animated: to after the animation runs to completion? (If you were to call, say, -resetNorth just before this point, the asynchronous animation could interfere with the bounds fitting.)

@1ec5 1ec5 added bug iOS Mapbox Maps SDK for iOS labels Jul 1, 2015
@picciano
Copy link
Author

picciano commented Jul 1, 2015

  1. For iPhone 5S the map frame is 0,0,204,196. For iPhone 6 the map frame is 0,0,359,295. Both do match my expectations
  2. Same results with animated:YES and animated:NO
  3. I am creating a new instance of map view, set userInteractionEnabled:YES, add map view as a subview to a UIView, add one polyline annotation and two point annotations, calculate my sw and ne corners and call setVisibleCoordinateBounds:edge:animated:NO You can see above that the coordinates are the same for both maps. The only difference that I can see is the frame size of the map view.

@picciano
Copy link
Author

picciano commented Jul 1, 2015

Edge padding is also the same in both cases.

@picciano
Copy link
Author

picciano commented Jul 1, 2015

Two more notes:

  1. The iPhone 6Plus also works correctly (like the iPhone 5S). So far, only the iPhone 6 is weird.
  2. I have another view with full screen maps with the same behavior, that is, working for iPhone 5S and 6 Plus, but not iPhone 6.

@picciano
Copy link
Author

picciano commented Jul 1, 2015

After some more research, this bug is being caused by the map's zoom level before calling this method. A zoom level of <6 causes a noticeable level of inaccuracy. The lower the zoom level (before calling this method) causes a larger discrepancy.

That's what causes the problem, but still unknown is why, and why it would only affect iPhone 6???!!

@1ec5
Copy link
Contributor

1ec5 commented Jul 2, 2015

I can reproduce this just as you describe: only on iPhone 6. I wasn’t noticing it before because the offset is an absolute distance, yet I was only testing fitting to rather large bounds, such as the shape of Colorado.

@1ec5 1ec5 changed the title setVisibleCoordinateBoundsedgePaddinganimated: not working for iPhone 6 setVisibleCoordinateBounds:edgePadding:animated: not working for iPhone 6 Jul 2, 2015
@1ec5
Copy link
Contributor

1ec5 commented Jul 2, 2015

The basic issue described in #1433 still persists to some extent: in Map::fitBounds(), centerLatLng differs based on the current zoom level. When I try to fit the idealized bounds of Colorado (37°N–41°N × 109°2′48″W–102.05°W) at z0 with 32 pixels of top padding on a portrait iPhone 6, centerLatLng is (39.441750492506543°N, 105.28772469824946°W). But if I do the same at approximately z5, centerLatLng is (39.265443576279353°N, 105.51573333333334°W), which is much closer to the correct value.

@1ec5
Copy link
Contributor

1ec5 commented Jul 2, 2015

(lldb) p latLngForPixel(pixelForLatLng({37, -102.05}))
(const mbgl::LatLng) $6 = (latitude = 37.149703818003474, longitude = -101.86236551985678)

@picciano
Copy link
Author

picciano commented Jul 2, 2015

nice, makes sense...now

@1ec5 1ec5 closed this as completed in #1827 Jul 2, 2015
@1ec5 1ec5 removed the in progress label Jul 2, 2015
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

2 participants