summaryrefslogtreecommitdiff
path: root/platform/darwin/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src')
-rw-r--r--platform/darwin/src/MGLLineStyleLayer.h44
-rw-r--r--platform/darwin/src/MGLLineStyleLayer.mm17
-rw-r--r--platform/darwin/src/MGLStyleLayer.mm.ejs2
3 files changed, 62 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h
index 1080244bdb..a7ac7f1462 100644
--- a/platform/darwin/src/MGLLineStyleLayer.h
+++ b/platform/darwin/src/MGLLineStyleLayer.h
@@ -366,6 +366,50 @@ MGL_EXPORT
*/
@property (nonatomic) MGLTransition lineGapWidthTransition;
+#if TARGET_OS_IPHONE
+/**
+ Defines a gradient with which to color a line feature. Can only be used with
+ GeoJSON sources that specify `"lineMetrics": true`.
+
+ This property is only applied to the style if `lineDasharray` is set to `nil`,
+ and `linePattern` is set to `nil`, and the data source requirements are met.
+ Otherwise, it is ignored.
+
+ You can set this property to an expression containing any of the following:
+
+ * Constant `UIColor` values
+ * Predefined functions, including mathematical and string operators
+ * Conditional expressions
+ * Variable assignments and references to assigned variables
+ * Interpolation and step functions applied to the `$lineProgress` variable
+
+ This property does not support applying interpolation or step functions to
+ feature attributes.
+ */
+@property (nonatomic, null_resettable) NSExpression *lineGradient;
+#else
+/**
+ Defines a gradient with which to color a line feature. Can only be used with
+ GeoJSON sources that specify `"lineMetrics": true`.
+
+ This property is only applied to the style if `lineDasharray` is set to `nil`,
+ and `linePattern` is set to `nil`, and the data source requirements are met.
+ Otherwise, it is ignored.
+
+ You can set this property to an expression containing any of the following:
+
+ * Constant `NSColor` values
+ * Predefined functions, including mathematical and string operators
+ * Conditional expressions
+ * Variable assignments and references to assigned variables
+ * Interpolation and step functions applied to the `$lineProgress` variable
+
+ This property does not support applying interpolation or step functions to
+ feature attributes.
+ */
+@property (nonatomic, null_resettable) NSExpression *lineGradient;
+#endif
+
/**
The line's offset. For linear features, a positive value offsets the line to
the right, relative to the direction of the line, and a negative value to the
diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm
index 3bad2a8b98..5cf0762475 100644
--- a/platform/darwin/src/MGLLineStyleLayer.mm
+++ b/platform/darwin/src/MGLLineStyleLayer.mm
@@ -306,6 +306,23 @@ namespace mbgl {
return transition;
}
+- (void)setLineGradient:(NSExpression *)lineGradient {
+ MGLAssertStyleLayerIsValid();
+
+ auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::ColorRampPropertyValue>(lineGradient);
+ self.rawLayer->setLineGradient(mbglValue);
+}
+
+- (NSExpression *)lineGradient {
+ MGLAssertStyleLayerIsValid();
+
+ auto propertyValue = self.rawLayer->getLineGradient();
+ if (propertyValue.isUndefined()) {
+ propertyValue = self.rawLayer->getDefaultLineGradient();
+ }
+ return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toExpression(propertyValue);
+}
+
- (void)setLineOffset:(NSExpression *)lineOffset {
MGLAssertStyleLayerIsValid();
diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs
index 0707e573c4..49ac04ce05 100644
--- a/platform/darwin/src/MGLStyleLayer.mm.ejs
+++ b/platform/darwin/src/MGLStyleLayer.mm.ejs
@@ -169,7 +169,7 @@ namespace mbgl {
<% switch (property['property-type']) {
case 'color-ramp': -%>
- auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::ColorRampPropertyValue>(heatmapColor);
+ auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::ColorRampPropertyValue>(<%- objCName(property) %>);
<% break
case 'data-driven':
case 'cross-faded-data-driven': -%>