-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Default anchor for icons #763
Comments
Can you use some illustrations and examples to better explain the problem and solution? |
Shields are a very bad example of how sprite json definition got ugly, I wouldn't use it to make a point... If I could, I would have removed it from the sorite spec and create a whole separate definition just for shields. |
If you are using stylemissingimage then why bother adding a spec definition (you are not using the style.json) anyway so you can code around it. |
Unless I'm missing something I would have to:
The issue here is that I don't know all of the possible icons when creating the style, which means I can't correctly fill in the icon offset/etc expressions. The spec definition for sprites defines the StyleImageMetadata typescript type, which is an argument to |
Design Proposal: Default anchor for icons
Motivation
Icon anchors are frequently the same for every different usage of the icons, and for dynamically created or loaded icons it is very difficult or impossible to provide them when writing the style. (mapbox/mapbox-gl-js#5369)
Proposed Change
Add intrinsic variations to most alignment and anchor options for symbol fields that read a default value that was defined in the sprite sheet or when the sprite was added to the map.
API Modifications
Add a
intrinsic
option to the icon-anchor, text-anchor, and text-justify style properties.Add a
intrinsic-text-anchor: [number, number]
,intrinsic-icon-anchor: [number, number]
, andintrinsic-text-justify: [ ... ]
to the sprite definitionMigration Plan and Compatibility
The new functionality is strictly additive so it should not require any changes by users. Users that use the same settings for every usage of a symbol may convert those declarations to using the intrinsic settings.
Rejected Alternatives
icon-position: [ "get", "default-icon-position", ["image", "your-image"]]
. This would work, but such a generic feature would need a lot more discussion / thought.The text was updated successfully, but these errors were encountered: