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

[ios] snap to north if interaction ends within ±7° - #3403

Merged
friedbunny merged 1 commit into
masterfrom
ios-compass-snap
Dec 24, 2015
Merged

friedbunny merged 1 commit into
masterfrom
ios-compass-snap

Conversation

@friedbunny

Copy link
Copy Markdown
Contributor

If a user pinch-rotates and the gesture ends within ±7° of north, reset to north (0°).

This behavior is the same as in MapKit.

First proposed in #938, implemented in #1059, reverted in #1064. (Closes #1064.)

/cc @1ec5

@friedbunny friedbunny added feature GL JS parity For feature parity with Mapbox GL JS iOS Mapbox Maps SDK for iOS labels Dec 23, 2015
@friedbunny friedbunny added this to the ios-v3.1.0 milestone Dec 23, 2015
@friedbunny

Copy link
Copy Markdown
Contributor Author

Going to leave this convenient iosapp debug code here:

- (void)mapViewRegionIsChanging:(__unused MGLMapView *)mapView
{
    [self updateDirectionDebug];
}
- (void)mapView:(__unused MGLMapView *)mapView regionDidChangeAnimated:(__unused BOOL)animated
{
    [self updateDirectionDebug];
}

- (void)updateDirectionDebug
{
    if (! _directionDebug)
    {
        _directionDebug = [[UILabel alloc] initWithFrame:CGRectMake(250, 100, 100, 50)];
        [self.view addSubview:_directionDebug];
    }

    _directionDebug.text = [NSString stringWithFormat:@"%.2f", self.mapView.direction];
}

@1ec5

1ec5 commented Dec 23, 2015

Copy link
Copy Markdown
Contributor

Could this be done as part of -unrotateIfNeededAnimated:?

@friedbunny

Copy link
Copy Markdown
Contributor Author

I'm looking into integrating it in -unrotateIfNeededAnimated:. That does get called rather frequently...

@friedbunny

Copy link
Copy Markdown
Contributor Author

I went ahead and integrated the snapping with -unrotateIfNeededAnimated:. This will cover more cases and be called more frequently.

I've not copied the delayed animations and disabled user interaction that exists just above in -unrotateIfNeededAnimated: because it does not appear to be necessary.

Comment thread platform/ios/src/MGLMapView.mm Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the developer hides the compass view? Shouldn’t the map view snap to north regardless?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will look at changing this.

@friedbunny

Copy link
Copy Markdown
Contributor Author

Ergh, accidentally included iosapp debug code. Will back that out.

@friedbunny friedbunny changed the title [ios] snap compass to north if gesture ends within ±7° [ios] snap to north if interaction ends within ±7° Dec 24, 2015
First proposed in #938, implemented in #1059, reverted in #1064.
@friedbunny

Copy link
Copy Markdown
Contributor Author

Rebased and squashed.

@friedbunny
friedbunny merged commit e4d8494 into master Dec 24, 2015
@friedbunny
friedbunny deleted the ios-compass-snap branch December 24, 2015 19:10
@friedbunny friedbunny self-assigned this Jan 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature GL JS parity For feature parity with Mapbox GL JS iOS Mapbox Maps SDK for iOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants