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

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

Merged
1ec5 merged 1 commit into
masterfrom
1ec5-attribute-color
Feb 18, 2017
Merged

1ec5 merged 1 commit into
masterfrom
1ec5-attribute-color

Conversation

@1ec5

@1ec5 1ec5 commented Feb 11, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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

@1ec5
1ec5 requested a review from anandthakker February 17, 2017 06:16
Comment thread platform/darwin/src/MGLFeature.h Outdated
`halfway`.

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

Copy link
Copy Markdown
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.

@1ec5 1ec5 mentioned this pull request Feb 17, 2017
16 of 18 tasks
…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.
@1ec5
1ec5 force-pushed the 1ec5-attribute-color branch from 03cdf6a to 556afae Compare February 17, 2017 22:41
@1ec5
1ec5 requested a review from anandthakker February 17, 2017 22:52

@anandthakker anandthakker left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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