mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

iconTextFit / iconTextFitPadding NSExpression forConstantValue not working (Crash)

Open pavelko3lov opened this issue 4 years ago • 0 comments

Steps to reproduce

  1. Take MGLSymbolStyleLayer with property iconTextFit or iconTextFitPadding.
  2. Then assign NSExpression like this:
 symbolStyleLayer.iconTextFit = NSExpression(
                        forConditional: NSPredicate(format: "%K == "isTextSmall"),
                        trueExpression: NSExpression(forConstantValue: "both"),
                        falseExpression: NSExpression(forConstantValue: "width")
                    )
symbolStyleLayer.text = .init(format: "%K", "myTitle")
  1. Creating MGLPointFeature with attribute:
let feature = MGLPointFeature()
feature.attributes = ["isTextSmall": true, "myTitle": "  where my spaces?  "]

then update layer with source

let shape = MGLShapeCollectionFeature(shapes: features)
(style.source(withIdentifier: source.rawValue) as? MGLShapeSource)?.shape = shape

Expected behavior

Works as well as for iconOpacity attribute for instance. The property depends on income value.

Actual behavior

App crashes with this error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid property value: data expressions not supported' terminating with uncaught exception of type NSException

PS. Why does MGLSymbolStyleLayer 'text' property trims spaces/tabs before it and at the end ? How can I add some extra spaces ?

Thanks for responses and advice.

Configuration

**Mapbox SDK versions: Mapbox-iOS-SDK (6.3.0) **iOS/macOS versions: iOS 14.4 **Device/simulator models: iphone X **Xcode version: 12.4 (12D4e)

pavelko3lov avatar Mar 14 '21 12:03 pavelko3lov