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.

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

Closed

Description

@picciano

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

Activity

  1. 1ec5 commented on Jul 1, 2015

    @1ec5
    Contributor

    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.)
  2. added
    iOS
    on Jul 1, 2015
  3. picciano commented on Jul 1, 2015

    @picciano
    Author
    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.
  4. picciano commented on Jul 1, 2015

    @picciano
    Author

    Edge padding is also the same in both cases.

  5. picciano commented on Jul 1, 2015

    @picciano
    Author

    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.
  6. picciano commented on Jul 1, 2015

    @picciano
    Author

    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???!!

  7. 1ec5 commented on Jul 2, 2015

    @1ec5
    Contributor

    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.

  8. changed the title [-]setVisibleCoordinateBoundsedgePaddinganimated: not working for iPhone 6[/-] [+]setVisibleCoordinateBounds:edgePadding:animated: not working for iPhone 6[/+] on Jul 2, 2015
  9. 1ec5 commented on Jul 2, 2015

    @1ec5
    Contributor

    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.

  10. 1ec5 commented on Jul 2, 2015

    @1ec5
    Contributor
    (lldb) p latLngForPixel(pixelForLatLng({37, -102.05}))
    (const mbgl::LatLng) $6 = (latitude = 37.149703818003474, longitude = -101.86236551985678)
    
  11. self-assigned this
    on Jul 2, 2015
  12. picciano commented on Jul 2, 2015

    @picciano
    Author

    nice, makes sense...now

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

Metadata

Metadata

Assignees

Labels

bugiOS

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions