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

[ios] Add permanent user heading indicator #9886

Merged
merged 11 commits into from
Sep 11, 2017

Conversation

friedbunny
Copy link
Contributor

@friedbunny friedbunny commented Aug 29, 2017

This is an WIP towards fixing #5523, adding a permanent user heading indicator (visible outside of heading tracking mode) and refactoring the user location annotation a bit.

To-do

  • Handle beam ↔ arrow heading indicator switching.
  • Rotate the arrow properly.
  • Make showsUserHeadingIndicator inspectable.
  • Test that various tint colors are legible.
  • Document relationship between showsUserHeadingIndicator and showsUserLocation.
  • Reevaluate if c01c1ab is necessary after [ios] Fix heading update loop #9845.
  • Make a call on whether or not to change the heading filter from 5° to 1°.
  • Clean up debug code.
  • Squash and reorganize commits.
  • Review from my lovely teammates.

/cc @1ec5 @fabian-guerra @jmkiley

@friedbunny friedbunny added feature Google Maps parity For feature parity with the Google Maps SDK for Android or iOS iOS Mapbox Maps SDK for iOS MapKit parity For feature parity with MapKit on iOS or macOS refactor labels Aug 29, 2017
@friedbunny friedbunny added this to the ios-v3.6.3 milestone Aug 29, 2017
@friedbunny friedbunny self-assigned this Aug 29, 2017
@friedbunny
Copy link
Contributor Author

friedbunny commented Aug 30, 2017

Preliminary design:

img_5463

Note sure if it would look better overlapping the white border or if it should stay outside. 🤔

/cc @mayagao

@fabian-guerra
Copy link
Contributor

Is it possible see the contrast between the arrow heading <-> beam indicator with Mapbox Streets and Dark styles?

@friedbunny
Copy link
Contributor Author

friedbunny commented Aug 31, 2017

e0b27fe adds a 1pt white stroke to the arrow and moves it on top of the outer white dot layer. I think this improves legibility with darker tint colors (and it’s kinda’ cute). 🐦

stroked-arrow

Still need to test this with different pixel densities and tint colors. Will also look at extending the shadow path to include the arrow.

Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

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

This is nice. I kind of want to borrow it for macOS SDK’s -[MGLCompassCell drawKnob:]. 😄


The default value of this property is `NO`.
*/
@property (nonatomic, assign) BOOL showsUserHeadingIndicator;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this property be inspectable? What happens if this property is set but showsUserLocation is not?

Copy link
Contributor Author

@friedbunny friedbunny Sep 1, 2017

Choose a reason for hiding this comment

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

Should this property be inspectable?

Sure, that would be useful — I’ll do it.

What happens if this property is set but showsUserLocation is not?

showsUserHeadingIndicator won’t do anything without showsUserLocation=YES — it doesn’t cause the user location annotation to appear. I considered having showsUserHeadingIndicator also implicitly enable showsUserLocation (the way our tracking modes do), but balked because it seemed a little too magical/indirect. Considering it again now, I could probably go either way. What do you think?

In any case, I’ll add documentation for this.

Copy link
Contributor Author

@friedbunny friedbunny Sep 1, 2017

Choose a reason for hiding this comment

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

Made this inspectable in 776a1c3 — renamed it for IB for disambiguation.

screen shot 2017-09-01 at 3 11 08 pm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fa692f8: now with less truncation.

screen shot 2017-09-01 at 3 24 11 pm

@friedbunny friedbunny force-pushed the fb-permaheading branch 2 times, most recently from 6dcd9a8 to cc81649 Compare September 6, 2017 23:07
@friedbunny
Copy link
Contributor Author

friedbunny commented Sep 6, 2017

I’ve rebased and reorganized this into digestible commits. I’m relatively happy with the state it’s in and would appreciate review from y’all. 🙇

A couple notes on the heading filter and disabled implicit animation:

  • The heading filter has been reduced to 1° (the default) from 5°, which smooths the rotation of the map and indicator by receiving/handling more heading updates.
  • Performance (in terms of FPS) in heading tracking mode should be essentially the same as before, as the heading indicator no longer has implicit animations bogging things down.
  • Perceived performance should be improved, as we no longer wait 5° between map updates (which could be jerky).
  • One downside: without the implicit animation, large heading changes will cause the indicator to jump. Ideally we would animate large changes, but I’d prefer to leave that as tail work.

/cc @fabian-guerra @1ec5 @frederoni

@friedbunny friedbunny removed the MapKit parity For feature parity with MapKit on iOS or macOS label Sep 6, 2017
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

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

It’s great to see MGLFaux3DUserLocationAnnotationView refactored this way, and the arrow’s design is a nice touch. Besides the relatively minor feedback below, would you do the honors and update the iOS changelog?

} else if (self.showZoomLevelEnabled) {
self.hudLabel.text = [NSString stringWithFormat:@" Zoom: %.2f", self.mapView.zoomLevel];
hudString = [NSString stringWithFormat:@"%.2f ∕ ↕\U0000FE0E%.f° ∕ %.f°", self.mapView.zoomLevel, self.mapView.camera.pitch, self.mapView.direction];
Copy link
Contributor

Choose a reason for hiding this comment

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

Verified that this is U+00B0 DEGREE SIGN. ✅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, this ends up looking like this in the label:

14.12 ∕ ↕︎45° ∕ 280°

... thanks to the good ole variation selector, which negates emoji conversion.

const CGFloat MGLUserLocationAnnotationHaloSize = 115.0;

const CGFloat MGLUserLocationAnnotationPuckSize = 45.0;
const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuckSize * 0.6;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these constants used anywhere outside of MGLFaux3DUserLocationAnnotationView.m? If not, I think they can stay in that file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They were during the initial refactor, but I ended up trying to avoid using these outside of MGLFaux3DUserLocationAnnotationView.m. I’ll see about moving these back to there.

Copy link
Contributor Author

@friedbunny friedbunny Sep 7, 2017

Choose a reason for hiding this comment

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

MGLUserLocationHeadingBeamLayer still needs MGLUserLocationAnnotationHaloSize, which unfortunately can’t be easily derived from the user location annotation itself.

CGFloat rotation = -MGLRadiansFromDegrees(self.mapView.direction - self.userLocation.heading.trueHeading);

// Don't rotate if the change is imperceptible (arbitrarily chosen as: 0.01 radians/~0.6°).
if (fabs(rotation) > 0.01)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hoist this up top as a constant. Worth noting that this tolerance is much smaller than the other angular tolerance, MGLToleranceForSnappingToNorth, but I think that’s OK because the unrotation animation is meant to be perceptible.

@friedbunny friedbunny changed the title [ios] WIP: Add permanent user heading indicator [ios] Add permanent user heading indicator Sep 7, 2017
The update steps for the heading indicator are typically small, so animations tend to pile up and cause performance issues. Disabling actions is a slight regression when it comes to large steps (they're not animated now, where they previously were) and this should eventually be addressed.

Also consistently use provided API for disabling CATransaction actions.
@friedbunny
Copy link
Contributor Author

Tests are failing on the release branch because of egl-node6-clang39-debug builds on Travis, such as this. Are you aware of any changes in master that we can cherry-pick to fix this, @brunoabinader @bsudekum?

@brunoabinader
Copy link
Member

Not really @friedbunny 😞 this is the first time I see this failure.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Google Maps parity For feature parity with the Google Maps SDK for Android or iOS iOS Mapbox Maps SDK for iOS refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants