-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Adding rotationAlignment: 'horizon' for markers on globe #11894
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
Conversation
… pitch-alignment:map in globe without change to 2d behavior
Co-authored-by: Karim Naaji <karim.naaji@gmail.com>
0d4af8e
to
ab55eca
Compare
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.
@karimnaaji I realized there was still a bit of vestigial logic accounting for the experimental horizon pitch alignment in #1642, so I've been able to simplify the code in a few places. It now seems that adding a
Whoops, forgot to commit the custom icon! 🤦 That's now fixed. |
const defaultHeight = 41; | ||
const defaultWidth = 27; |
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.
nit: Why move these out? I'd prefer locality, so the values aren't few hundreds of code lines away.
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.
My thought was that this makes them less magic-numbery and more consistent with the other constants defined at the start of the file, but that's a good point. Do you think that ALIGN_TO_HORIZON_BELOW_ZOOM
and ALIGN_TO_HORIZON_ABOVE_ZOOM
should also be defined closer to where they are used?
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.
Do you think that ALIGN_TO_HORIZON_BELOW_ZOOM and ALIGN_TO_HORIZON_ABOVE_ZOOM should also be defined closer to where they are used?
I think so, since they're not really shared by anything else and not exported for use outside of this file, it's probably good to keep it local to the block they're used in as well instead of in the global scope. Being consistent in naming would also make sense if you keep here, e.g. making these two variables all caps similar to the other ones.
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.
Looks great! One last nit to address in #11894 (comment) either by making the naming consistent or moving it back to local scope, but otherwise good to merge.
It would be great once 2.9.1 gets released to update the public documentation with the example from markers-custom
, so that we have better visibility for that option. Could you open a ticket so we follow up on that?
Takeaway from the discussion in #11642 is that a globe-oriented rotation alignment property is useful (but not a pitch alignment), and the clearest name for the property is "horizon." This PR adds that feature accordingly.
As the map zooms in and transitions from globe to Mercator, markers smoothly transition into
rotationAlignment: viewport
behavior.marker-transition.mov
With custom pin markers:
pin-demoo.mov
Launch Checklist
@mapbox/map-design-team
@mapbox/static-apis
if this PR includes style spec API or visual changesmapbox-gl-js
changelog:<changelog>Adding new marker styling option: rotationAlignment: 'horizon' allowing marker rotation to match the curvature of the horizon in globe view</changelog>
cc @mapbox/map-design-team