-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios] Add permanent user heading indicator #9886
[ios] Add permanent user heading indicator #9886
Conversation
Preliminary design: Note sure if it would look better overlapping the white border or if it should stay outside. 🤔 /cc @mayagao |
Is it possible see the contrast between the arrow heading <-> beam indicator with Mapbox Streets and Dark styles? |
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). 🐦 Still need to test this with different pixel densities and tint colors. Will also look at extending the shadow path to include the arrow. |
There was a problem hiding this 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
776a1c3
to
fa692f8
Compare
fa692f8
to
7c7ced9
Compare
6dcd9a8
to
cc81649
Compare
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:
|
There was a problem hiding this 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]; |
There was a problem hiding this comment.
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. ✅
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
The default is 1.
Rename it to `showsHeading` to fit in the tiny label column of the utilities panel.
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.
cc81649
to
efe9928
Compare
Tests are failing on the release branch because of |
Not really @friedbunny 😞 this is the first time I see this failure. |
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
showsUserHeadingIndicator
inspectable.showsUserHeadingIndicator
andshowsUserLocation
./cc @1ec5 @fabian-guerra @jmkiley