Skip to content

textVariableAnchor style for SymbolLayer works on iOS#3208

Merged
mfazekas merged 1 commit intornmapbox:mainfrom
MichaelDanielTom:textVariableAnchorIos
Dec 2, 2023
Merged

textVariableAnchor style for SymbolLayer works on iOS#3208
mfazekas merged 1 commit intornmapbox:mainfrom
MichaelDanielTom:textVariableAnchorIos

Conversation

@MichaelDanielTom
Copy link
Contributor

Fixes #3105 on iOS

@mfazekas
Copy link
Contributor

@MichaelDanielTom thanks much, looks great.
In future it can be generalised so we can reuse for all array of enums like mglStyleValueArrayTextWritingMode

func mglStyleValueEnum<Enum : RawRepresentable>() -> Value<Enum> where Enum.RawValue == String {
if let value = value as? Dictionary<String,Any> {
let value = RNMBXStyleValue.convert(value["stylevalue"] as! [String:Any])
if let value = value as? String {
return Value.constant(Enum(rawValue: value )!)
} else if let value = value as? [Any] {
if let parsedExpression = (logged("mglStyleValueEnum: failed to parse expression") {
try parseExpression(value)
}) {
return .expression(parsedExpression)
} else {
return Value.constant(Enum(rawValue: value[0] as! String)!)
}
} else {
Logger.log(level: .error, message:"Invalid value for enum (nor string, not array): \(value) returning something")
return Value.constant(Enum(rawValue: value as! String)!)
}
} else {
Logger.log(level: .error, message:"Invalid value for enum: \(value) returning something")
return Value.constant(Enum(rawValue: value as! String)!)
}
}

@MichaelDanielTom
Copy link
Contributor Author

MichaelDanielTom commented Nov 29, 2023

@mfazekas just force pushed something that changed map to compactMap - was building properly in my project with the former but not building with the example project. Using compactMap works with the example project too. Not sure if the difference was a swift version, caching issue, or something else.

@mfazekas mfazekas merged commit a20e541 into rnmapbox:main Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: textVariableAnchor does not do anything (symbolLayer)

2 participants