use of com.mapbox.mapboxsdk.style.expressions.Expression in project mapbox-plugins-android by mapbox.
the class LocalizationPlugin method convertExpression.
private void convertExpression(@NonNull MapLocale mapLocale, Layer layer, PropertyValue<?> textFieldProperty, boolean isStreetsV7) {
Expression textFieldExpression = textFieldProperty.getExpression();
if (textFieldExpression != null) {
MapLocale newMapLocale = mapLocale;
String mapLanguage = mapLocale.getMapLanguage();
if (mapLanguage.startsWith("name_zh")) {
// need to re-get mapLocale, since the default is for street-v8
newMapLocale = getChineseMapLocale(mapLocale, isStreetsV7);
Timber.d("reset mapLocale to: %s", newMapLocale.getMapLanguage());
}
String text = textFieldExpression.toString().replaceAll(EXPRESSION_REGEX, newMapLocale.getMapLanguage());
if (text.startsWith("[\"step") && textFieldExpression.toArray().length % 2 == 0) {
// got an invalid step expression from core, we need to add an additional name_x into step
text = text.replaceAll(STEP_REGEX, STEP_TEMPLATE);
}
layer.setProperties(textField(raw(text)));
}
}
Aggregations