summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java5
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java20
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java28
-rw-r--r--platform/android/src/style/layers/symbol_layer.cpp6
-rw-r--r--platform/android/src/style/layers/symbol_layer.hpp2
6 files changed, 76 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
index 57cf6271c9..84285a1c54 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
@@ -111,6 +111,10 @@ public final class Property {
// SYMBOL_Z_ORDER: Controls the order in which overlapping symbols in the same layer are rendered
/**
+ * If {@link SYMBOL_SORT_KEY} is set, sort based on that. Otherwise sort symbols by their position relative to the viewport.
+ */
+ public static final String SYMBOL_Z_ORDER_AUTO = "auto";
+ /**
* Symbols will be sorted by their y-position relative to the viewport.
*/
public static final String SYMBOL_Z_ORDER_VIEWPORT_Y = "viewport-y";
@@ -123,6 +127,7 @@ public final class Property {
* Controls the order in which overlapping symbols in the same layer are rendered
*/
@StringDef({
+ SYMBOL_Z_ORDER_AUTO,
SYMBOL_Z_ORDER_VIEWPORT_Y,
SYMBOL_Z_ORDER_SOURCE,
})
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 01908b1b0b..43a1c8daac 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
@@ -1786,6 +1786,26 @@ public class PropertyFactory {
}
/**
+ * Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key wehn they overlap. Features with a lower sort key will have priority over other features when doing placement.
+ *
+ * @param value a Float value
+ * @return property wrapper around Float
+ */
+ public static PropertyValue<Float> symbolSortKey(Float value) {
+ return new LayoutPropertyValue<>("symbol-sort-key", value);
+ }
+
+ /**
+ * Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key wehn they overlap. Features with a lower sort key will have priority over other features when doing placement.
+ *
+ * @param value a Float value
+ * @return property wrapper around Float
+ */
+ public static PropertyValue<Expression> symbolSortKey(Expression value) {
+ return new LayoutPropertyValue<>("symbol-sort-key", value);
+ }
+
+ /**
* Controls the order in which overlapping symbols in the same layer are rendered
*
* @param value a String value
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
index 75473f0f30..1d8bad7e8e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
@@ -182,6 +182,18 @@ public class SymbolLayer extends Layer {
}
/**
+ * Get the SymbolSortKey property
+ *
+ * @return property wrapper value around Float
+ */
+ @NonNull
+ @SuppressWarnings("unchecked")
+ public PropertyValue<Float> getSymbolSortKey() {
+ checkThread();
+ return (PropertyValue<Float>) new PropertyValue("symbol-sort-key", nativeGetSymbolSortKey());
+ }
+
+ /**
* Get the SymbolZOrder property
*
* @return property wrapper value around String
@@ -1115,6 +1127,10 @@ public class SymbolLayer extends Layer {
@NonNull
@Keep
+ private native Object nativeGetSymbolSortKey();
+
+ @NonNull
+ @Keep
private native Object nativeGetSymbolZOrder();
@NonNull
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
index ae2c6d98f6..4674c9ffb1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
@@ -142,13 +142,39 @@ public class SymbolLayerTest extends BaseLayerTest {
@Test
@UiThreadTest
+ public void testSymbolSortKeyAsConstant() {
+ Timber.i("symbol-sort-key");
+ assertNotNull(layer);
+ assertNull(layer.getSymbolSortKey().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(symbolSortKey(propertyValue));
+ assertEquals(layer.getSymbolSortKey().getValue(), propertyValue);
+ }
+
+ @Test
+ @UiThreadTest
+ public void testSymbolSortKeyAsExpression() {
+ Timber.i("symbol-sort-key-expression");
+ assertNotNull(layer);
+ assertNull(layer.getSymbolSortKey().getExpression());
+
+ // Set and Get
+ Expression expression = number(Expression.get("undefined"));
+ layer.setProperties(symbolSortKey(expression));
+ assertEquals(layer.getSymbolSortKey().getExpression(), expression);
+ }
+
+ @Test
+ @UiThreadTest
public void testSymbolZOrderAsConstant() {
Timber.i("symbol-z-order");
assertNotNull(layer);
assertNull(layer.getSymbolZOrder().getValue());
// Set and Get
- String propertyValue = SYMBOL_Z_ORDER_VIEWPORT_Y;
+ String propertyValue = SYMBOL_Z_ORDER_AUTO;
layer.setProperties(symbolZOrder(propertyValue));
assertEquals(layer.getSymbolZOrder().getValue(), propertyValue);
}
diff --git a/platform/android/src/style/layers/symbol_layer.cpp b/platform/android/src/style/layers/symbol_layer.cpp
index 810848e9cb..fb06255913 100644
--- a/platform/android/src/style/layers/symbol_layer.cpp
+++ b/platform/android/src/style/layers/symbol_layer.cpp
@@ -56,6 +56,11 @@ namespace android {
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getSymbolAvoidEdges()));
}
+ jni::Local<jni::Object<>> SymbolLayer::getSymbolSortKey(jni::JNIEnv& env) {
+ using namespace mbgl::android::conversion;
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getSymbolSortKey()));
+ }
+
jni::Local<jni::Object<>> SymbolLayer::getSymbolZOrder(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getSymbolZOrder()));
@@ -500,6 +505,7 @@ namespace android {
METHOD(&SymbolLayer::getSymbolPlacement, "nativeGetSymbolPlacement"),
METHOD(&SymbolLayer::getSymbolSpacing, "nativeGetSymbolSpacing"),
METHOD(&SymbolLayer::getSymbolAvoidEdges, "nativeGetSymbolAvoidEdges"),
+ METHOD(&SymbolLayer::getSymbolSortKey, "nativeGetSymbolSortKey"),
METHOD(&SymbolLayer::getSymbolZOrder, "nativeGetSymbolZOrder"),
METHOD(&SymbolLayer::getIconAllowOverlap, "nativeGetIconAllowOverlap"),
METHOD(&SymbolLayer::getIconIgnorePlacement, "nativeGetIconIgnorePlacement"),
diff --git a/platform/android/src/style/layers/symbol_layer.hpp b/platform/android/src/style/layers/symbol_layer.hpp
index 3b0f8ee5d1..d2ced89191 100644
--- a/platform/android/src/style/layers/symbol_layer.hpp
+++ b/platform/android/src/style/layers/symbol_layer.hpp
@@ -32,6 +32,8 @@ public:
jni::Local<jni::Object<jni::ObjectTag>> getSymbolAvoidEdges(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getSymbolSortKey(jni::JNIEnv&);
+
jni::Local<jni::Object<jni::ObjectTag>> getSymbolZOrder(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getIconAllowOverlap(jni::JNIEnv&);