summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java28
1 files changed, 27 insertions, 1 deletions
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 1d45f34bd3..7b9128343c 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
@@ -13,6 +13,8 @@ import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;
import com.google.gson.JsonArray;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
+import com.mapbox.mapboxsdk.style.types.Formatted;
+import com.mapbox.mapboxsdk.style.types.FormattedSection;
/**
* An icon or a text label.
@@ -365,7 +367,31 @@ public class SymbolLayer extends Layer {
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextField() {
checkThread();
- return (PropertyValue<String>) new PropertyValue("text-field", nativeGetTextField());
+
+ PropertyValue propertyValue = new PropertyValue<>("text-field", nativeGetTextField());
+ if (propertyValue.isExpression()) {
+ return (PropertyValue<String>) propertyValue;
+ } else {
+ Formatted formatted = (Formatted) nativeGetTextField();
+ StringBuilder builder = new StringBuilder();
+ for (FormattedSection section : formatted.getFormattedSections()) {
+ builder.append(section.getText());
+ }
+
+ return (PropertyValue<String>) new PropertyValue("text-field", builder.toString());
+ }
+ }
+
+ /**
+ * Get the TextField property as {@link Formatted} object
+ *
+ * @return property wrapper value around String
+ * @see Expression#format(Expression...)
+ */
+ @SuppressWarnings("unchecked")
+ public PropertyValue<Formatted> getFormattedTextField() {
+ checkThread();
+ return (PropertyValue<Formatted>) new PropertyValue("text-field", nativeGetTextField());
}
/**