I have a geojson with a thousand of features with different properties.
Some properties are arrays like: options: [foo, bar, buz]
.
And i need to filter features by values from these arrays, but i stuck on the building filters dynamically in runtime.
For filtering I trying to use the next expression:
layer.filter = Exp(.all) {
Exp(.get) { "foo" }
Exp(.get) { "bar" }
}
Everything working fine. But i don't understand how to create this expression from array of inputs? I tried to map array to filters like:
layer.filter = Exp(.all) {
["foo", "bar"].map { filter in
Exp(.get) { filter }
}
}
and i got error:
Swift.DecodingError.typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [RootCodingKeys(stringValue: "filter", intValue: nil)], debugDescription: "Expected to decode Array<Any> but found a number instead.", underlyingError: nil))
I cannot find any docs or samples how to build .all
expression in Mapbox iOS SDK.
I know that it's possible, to create filter like this on Android, but what is the correct way to implement it on iOS?
So, I found the correct way: