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

Convert NSColor/UIColor expressions to CSS color string values #8025

Merged
merged 1 commit into from
Feb 18, 2017

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Feb 11, 2017

When converting a constant NSExpression to an mbgl::Value, turn an NSColor or UIColor into an std::string containing a CSS color string. This allows developers to set an attribute of an MGLFeature to an NSColor or UIColor (rather than a CSS color string, which would be foreign), then use it in an MGLStyleFunction with identity interpolation.

Along the way, I added language to MGLFeature.attributes’ documentation to talk about the use of feature attributes in identity-interpolated style functions. I also simplified the NSExpression unit tests to more specifically test the category methods that convert constant NSExpressions to mbgl::Values, without going through NSPredicate. Normally I’d be hesitant to rely so heavily on macros, which makes debugging more difficult, but the existing tests rely on for loops, which make test failures just as difficult to diagnose.

/cc @boundsj @jfirebaugh

@1ec5 1ec5 added feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor runtime styling labels Feb 11, 2017
@1ec5 1ec5 added this to the ios-v3.5.0 milestone Feb 11, 2017
@1ec5 1ec5 self-assigned this Feb 11, 2017
@1ec5 1ec5 requested a review from incanus February 11, 2017 01:51
@mention-bot
Copy link

@1ec5, thanks for your PR! By analyzing this pull request, we identified @incanus, @jfirebaugh and @boundsj to be potential reviewers.

`halfway`.

The `MGLSymbolStyleLayer.textField` and `MGLSymbolStyleLayer.iconImageName`
properties use attributes in a slightly different way. For example, to label
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be more accurate to say that these properties "can use attributes in a slightly different way", or "can also use attributes in a second way" -- because once #7944 goes in, the source-function-based approach described in the previous paragraph would also apply to these.

…values

When converting a constant NSExpression to an mbgl::Value, turn an NSColor or UIColor into an std::string containing a CSS color string. This allows developers to set an attribute of an MGLFeature to an NSColor or UIColor (rather than a CSS color string, which would be foreign), then use it in an MGLStyleFunction with identity interpolation.
Copy link
Contributor

@anandthakker anandthakker left a comment

Choose a reason for hiding this comment

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

LGTM -- one comment inline, but not gonna hold up the Approve for that, since I'm not familiar with the docs overall.

attribute to each of the source’s features, then set
`MGLCircleStyleLayer.circleRadius` to an `MGLStyleValue` object with an
interpolation mode of `MGLInterpolationModeIdentity` and an attribute name of
`halfway`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ack, this didn't occur to me earlier, but would this be a good place to suggest referring to the DDS support tables to for those properties where ^ this approach is actually available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MGLCircleStyleLayer.circleRadius will link automatically to the documentation for that property, which like all layout and paint properties will list the interpolation modes and function types that are supported. I would like to refer the developer to a guide on data-driven styling, once it’s written as part of #7924.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor runtime styling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants