Skip to content
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

_normalizeBearing kills rotations <4.5º and resets to north #1055

Closed
friedbunny opened this issue Mar 5, 2015 · 3 comments
Closed

_normalizeBearing kills rotations <4.5º and resets to north #1055

friedbunny opened this issue Mar 5, 2015 · 3 comments
Assignees
Labels
Milestone

Comments

@friedbunny
Copy link
Contributor

When dragging the compass navigation control to rotate the map, rotations less than 4.5º are normalized to 0.

The relevant code in js/ui/easings.js (L341-L348):

// convert bearing so that it's numerically close to the current one so that it interpolates properly
_normalizeBearing: function(bearing, currentBearing) {
    bearing = util.wrap(bearing, -180, 180);
    var diff = Math.abs(bearing - currentBearing);
    if (Math.abs(bearing - 360 - currentBearing) < diff) bearing -= 360;
    if (Math.abs(bearing + 360 - currentBearing) < diff) bearing += 360;
    return bearing;
},

Also see @mourner's original commit f5c640a.

Personally, I view ignoring bearing changes that end ~±7º of north as a UX enhancement (mapbox/mapbox-gl-native/pull/938), but this current implementation acts on relative bearing changes and results in small rotations resetting the rotation entirely, regardless of the current bearing.

@mourner mourner added this to the 0.8 milestone Mar 5, 2015
@jfirebaugh jfirebaugh self-assigned this Mar 5, 2015
@jfirebaugh
Copy link
Contributor

Hmm, this is not from _normalizeBearing but from a click event getting triggered on the button at the end of the gesture and thus resetting to north. Will fix.

@friedbunny
Copy link
Contributor Author

That does make more sense, I figured I just wasn't seeing the problem with the math. Thanks @jfirebaugh, and sorry to impugn your arithmetic, @mourner. 😉

As an aside, is there enough interest in non-bug-induced compass snapping that I should spin that off into its own discussion?

@jfirebaugh
Copy link
Contributor

@friedbunny Yes, please open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants