summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java31
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java30
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs2
-rw-r--r--platform/android/src/style/layers/line_layer.cpp9
-rw-r--r--platform/android/src/style/layers/line_layer.hpp2
-rwxr-xr-xplatform/darwin/scripts/generate-style-code.js2
-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
-rw-r--r--platform/node/test/ignores.json2
10 files changed, 136 insertions, 5 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java
index d6519c991f..9130bfd76f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java
@@ -478,6 +478,34 @@ public class LineLayer extends Layer {
nativeSetLinePatternTransition(options.getDuration(), options.getDelay());
}
+ /**
+ * Get the LineGradient property
+ *
+ * @return property wrapper value around String
+ */
+ @SuppressWarnings("unchecked")
+ public PropertyValue<String> getLineGradient() {
+ checkThread();
+ return (PropertyValue<String>) new PropertyValue("line-gradient", nativeGetLineGradient());
+ }
+
+ /**
+ * Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
+ *
+ * @return int representation of a rgba string color
+ * @throws RuntimeException thrown if property isn't a value
+ */
+ @ColorInt
+ public int getLineGradientAsInt() {
+ checkThread();
+ PropertyValue<String> value = getLineGradient();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("line-gradient was set as a Function");
+ }
+ }
+
@Keep
private native Object nativeGetLineCap();
@@ -574,6 +602,9 @@ public class LineLayer extends Layer {
@Keep
private native void nativeSetLinePatternTransition(long duration, long delay);
+ @Keep
+ private native Object nativeGetLineGradient();
+
@Override
@Keep
protected native void finalize() throws Throwable;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
index cd7bd473f3..c619d0141a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
@@ -395,6 +395,36 @@ public class PropertyFactory {
}
/**
+ * Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
+ *
+ * @param value a int color value
+ * @return property wrapper around String color
+ */
+ public static PropertyValue<String> lineGradient(@ColorInt int value) {
+ return new PaintPropertyValue<>("line-gradient", colorToRgbaString(value));
+ }
+
+ /**
+ * Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
+ *
+ * @param value a String value
+ * @return property wrapper around String
+ */
+ public static PropertyValue<String> lineGradient(String value) {
+ return new PaintPropertyValue<>("line-gradient", value);
+ }
+
+ /**
+ * Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
+ *
+ * @param expression an expression statement
+ * @return property wrapper around an expression statement
+ */
+ public static PropertyValue<Expression> lineGradient(Expression expression) {
+ return new PaintPropertyValue<>("line-gradient", expression);
+ }
+
+ /**
* The opacity at which the icon will be drawn.
*
* @param value a Float value
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs
index 8acfc88dfa..a319d52ea3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs
@@ -118,7 +118,7 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
<% } -%>
<% for (const property of properties) { -%>
-<% if (property.name != 'heatmap-color') { -%>
+<% if (property['property-type'] !== 'color-ramp') { -%>
<% if (property.transition) { -%>
@Test
diff --git a/platform/android/src/style/layers/line_layer.cpp b/platform/android/src/style/layers/line_layer.cpp
index af4e24523e..f143ecc236 100644
--- a/platform/android/src/style/layers/line_layer.cpp
+++ b/platform/android/src/style/layers/line_layer.cpp
@@ -236,6 +236,12 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLinePatternTransition(options);
}
+ jni::Object<jni::ObjectTag> LineLayer::getLineGradient(jni::JNIEnv& env) {
+ using namespace mbgl::android::conversion;
+ Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineGradient());
+ return jni::Object<jni::ObjectTag>(*converted);
+ }
+
jni::Class<LineLayer> LineLayer::javaClass;
@@ -287,7 +293,8 @@ namespace android {
METHOD(&LineLayer::getLineDasharray, "nativeGetLineDasharray"),
METHOD(&LineLayer::getLinePatternTransition, "nativeGetLinePatternTransition"),
METHOD(&LineLayer::setLinePatternTransition, "nativeSetLinePatternTransition"),
- METHOD(&LineLayer::getLinePattern, "nativeGetLinePattern"));
+ METHOD(&LineLayer::getLinePattern, "nativeGetLinePattern"),
+ METHOD(&LineLayer::getLineGradient, "nativeGetLineGradient"));
}
} // namespace android
diff --git a/platform/android/src/style/layers/line_layer.hpp b/platform/android/src/style/layers/line_layer.hpp
index 84ecc77139..9eef1349cb 100644
--- a/platform/android/src/style/layers/line_layer.hpp
+++ b/platform/android/src/style/layers/line_layer.hpp
@@ -74,6 +74,8 @@ public:
jni::Object<jni::ObjectTag> getLinePattern(jni::JNIEnv&);
void setLinePatternTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Object<TransitionOptions> getLinePatternTransition(jni::JNIEnv&);
+
+ jni::Object<jni::ObjectTag> getLineGradient(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);
}; // class LineLayer
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js
index e89a4e29a3..bc676e9cba 100755
--- a/platform/darwin/scripts/generate-style-code.js
+++ b/platform/darwin/scripts/generate-style-code.js
@@ -367,6 +367,8 @@ global.propertyReqs = function (property, propertiesByName, type) {
return '`' + camelizeWithLeadingLowercase(req['!']) + '` is set to `nil`';
} else {
let name = Object.keys(req)[0];
+ if (name === 'source')
+ return 'the data source requirements are met';
return '`' + camelizeWithLeadingLowercase(name) + '` is set to an expression that evaluates to ' + describeValue(req[name], propertiesByName[name], type);
}
}).join(', and ') + '. Otherwise, it is ignored.';
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': -%>
diff --git a/platform/node/test/ignores.json b/platform/node/test/ignores.json
index 2d46317a95..0cbe550c0e 100644
--- a/platform/node/test/ignores.json
+++ b/platform/node/test/ignores.json
@@ -43,8 +43,6 @@
"render-tests/geojson/inline-polygon-symbol": "behavior needs reconciliation with gl-js",
"render-tests/icon-rotate/with-offset": "https://github.com/mapbox/mapbox-gl-native/issues/11872",
"render-tests/icon-no-cross-source-collision/default": "skip - gl-js only",
- "render-tests/line-gradient/gradient": "https://github.com/mapbox/mapbox-gl-native/issues/11718",
- "render-tests/line-gradient/translucent": "https://github.com/mapbox/mapbox-gl-native/issues/11718",
"render-tests/mixed-zoom/z10-z11": "https://github.com/mapbox/mapbox-gl-native/issues/10397",
"render-tests/raster-masking/overlapping-zoom": "https://github.com/mapbox/mapbox-gl-native/issues/10195",
"render-tests/real-world/bangkok": "https://github.com/mapbox/mapbox-gl-native/issues/10412",