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 misinterprets eye coordinate #12967

Closed

Description

@1ec5

+[MGLMapCamera cameraLookingAtCenterCoordinate:fromEyeCoordinate:eyeAltitude:] calculates a pitch in radians and passes it into -initWithCenterCoordinate:altitude:pitch:heading:, which expects the pitch in degrees, so the resulting MGLMapCamera has much less of a pitch than expected, the wrong heading, and a shorter viewing distance – so the eyeCoordinate parameter doesn’t have the intended effect. If the tangent happened to be negative, then MGLMapView would ignore the pitch altogether.

heading = std::atan((centerMeters.northing() - eyeMeters.northing()) /
(centerMeters.easting() - eyeMeters.easting()));
pitch = std::atan(eyeAltitude / groundDistance);

This significant discrepancy has apparently always been present in the MGLMapCamera implementation, since #2193. Unlike #12943, I think it would be tenable to fix the bug in-place, because the developer’s intent by using this method is pretty clear.

/cc @mapbox/maps-ios @d-prukop

Activity

  1. added
    iOS
    macOS
    navigation
    MapKit parity
    on Sep 26, 2018
  2. 1ec5 commented on Sep 27, 2018

    @1ec5
    ContributorAuthor

    If you pass the same coordinate twice into +[MGLMapCamera cameraLookingAtCenterCoordinate:fromEyeCoordinate:eyeAltitude:], the resulting camera incorrectly has a pitch of about 1.5° (a right angle in radians, but interpreted as degrees) instead of 0° and a heading of NaN instead of 0°.

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

    MapKit paritybugiOSmacOSnavigation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions