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.

MGLMapCamera(lookingAtCenter:, fromDistance:, pitch:, heading:) is not respecting content insets properly.  #12728

Closed

Description

@Gerungofulus

Steps to reproduce

  1. Set the content insets with a high (but not invalid) right inset. I tested it with a right inset of 370 in landscape mode.
  2. Use MGLMapCamera(lookingAtCenter:, fromDistance:, pitch:, heading:) to create a new camera looking at some coordinate. I used distance 1840, pitch 60, heading 184.
  3. Call fly(to: newCamera, withDuration: 1.25, completionHandler: nil) with the new camera

Expected behavior

  • The center coordinate is located in the center of the area of the view minus the insets
  • The pitch is set correctly
  • The distance is set correctly
  • A marker oriented into a special direction put right at the center coordinate should point up. In other words: The vanishing point should be located right above the new center coordinate, but it is still located in the center of the view, even though the content insets are set properly. (please see the image below. I also added text to the two crosses)

Configuration

Mapbox SDK versions:
4.2.0
iOS/macOS versions:
11.4.1 (15G77)
Device/simulator models:
iPhone 6s+ in Landscape
Xcode version:
9.4.1 (9F2000)
img_02c88c9455d2-1

Activity

  1. added
    iOS
    on Aug 24, 2018
  2. 1ec5 commented on Sep 13, 2018

    @1ec5
    Contributor

    fly(to:withDuration:completionHandler:) does seem to apply the content insets:

    mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera edgePadding:self.contentInsets];
    options.padding = MGLEdgeInsetsFromNSEdgeInsets(edgePadding);
    ScreenCoordinate center = getScreenCoordinate(padding);
    center.y = state.size.height - center.y;

    However, I think the problem you’ve identified is that the vanishing point is always located at the center-top of the view. Core GL doesn’t offer any way to move the vanishing point; ultimately, edge insets are implemented by changing the frame of reference for a center coordinate.

    /cc @ansis @brunoabinader @d-prukop

  3. added
    Core
    navigation
    and removed
    iOS
    on Sep 13, 2018
  4. 1ec5 commented on Sep 13, 2018

    @1ec5
    Contributor

    The workaround in @Gerungofulus’s case is to reduce the map view’s width to avoid the area taken up by the right panel. This only works because the right panel appears to be opaque and takes up the whole right side of the map view.

    In cases where the panel is translucent or doesn’t extend to the top and bottom edges of the window, a rather unsatisfying workaround would be to extend the map view further to the left, beyond the left edge of the containing view, until the vanishing point shifts sufficiently to the left.

  5. added
    archived
    on Mar 12, 2019
  6. stale commented on Mar 12, 2019

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

  7. 1ec5 commented on Mar 22, 2019

    @1ec5
    Contributor

    In cases where the panel is translucent or doesn’t extend to the top and bottom edges of the window, a rather unsatisfying workaround would be to extend the map view further to the left, beyond the left edge of the containing view, until the vanishing point shifts sufficiently to the left.

    This is the rather unsatisfying workaround we’ve settled on in the navigation SDK’s CarPlay integration: mapbox/mapbox-navigation-ios#1845.

    However, I think the problem you’ve identified is that the vanishing point is always located at the center-top of the view. Core GL doesn’t offer any way to move the vanishing point; ultimately, edge insets are implemented by changing the frame of reference for a center coordinate.

    Configuring the vanishing point is an important feature for navigation use cases. It’s common for landscape layouts to overlay a large sidebar that doesn’t completely obscure the map but does shift the horizontal center visually.

  8. reopened this on Mar 22, 2019
  9. removed
    archived
    on Mar 22, 2019
  10. astojilj commented on May 23, 2019

    @astojilj
    Contributor

    In cases where the panel is translucent or doesn’t extend to the top and bottom edges of the window, a rather unsatisfying workaround would be to extend the map view further to the left, beyond the left edge of the containing view, until the vanishing point shifts sufficiently to the left.

    This is the rather unsatisfying workaround we’ve settled on in the navigation SDK’s CarPlay integration: mapbox/mapbox-navigation-ios#1845.

    This is fixed in #14664.
    It's waiting for review.
    Note that current "workaround" should keep functioning as intended after the PR #14664 lands - if navigation-ios is just enlarging the view and offsetting it.
    If MGLMapView.contentInset is specified, center of perspective, and the user puck, will always be centered in the center of content area specified by contentInset; vanishing point would be above it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Corebugnavigation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions