Open tobias-r opened 6 months ago
@tobias-r please try with array expression instead of constructing a list literal
You mean this way? Then the app crashes with the following error:
com.mapbox.maps.MapboxStyleException: Add layer failed: Failed to set icon-translate
property for count
layer. Error: [2][1]: The item type argument of "array" must be one of string, number, boolean
val arrayExpressionWithIcon = Expression.array(
Expression.literal(10.0),
Expression.literal(-10.0)
)
val arrayExpressionWithoutIcon = Expression.array(
Expression.literal(6.0),
Expression.literal(-6.0)
)
iconTranslate(
Expression.switchCase(
Expression.eq(Expression.get("has-icon"), Expression.literal(true)),
arrayExpressionWithIcon,
arrayExpressionWithoutIcon
))
Hey @tobias-r , I tried to replicate your expression as follows using Expression DSL and it works as expected:
import com.mapbox.maps.extension.style.expressions.dsl.generated.*
switchCase {
eq {
get("has-icon")
literal(true)
}
literal(listOf(0.7, 0.7))
literal(listOf(0.7, 0.7))
}
however, it seems like iconTranslate
is a constant data type and doesn't support data driven expressions(e.g. get
expression)
Ok, got it, that's the reason then. Could you maybe change this in a future release?
I am using this in a cluster layer and not all the features have the same size. So i need to move the little bubble with the cluster count to different positions, depending on the size of the cluster. One that has an icon => "has-icon" and one that doesn't. It seems currently impossible or am I wrong?
Thanks very much for the feedback, I appreciate it!
Environment
Android SDK 11.3.1
Observed behavior and steps to reproduce
Notes / preliminary analysis
This code gives me the error: Cannot access 'literal': it is internal in 'Companion' It makes sense, but how else should I do it then?
Apparently this has been a bug in SDK 10 before (there is a Github bug ticket) and it is supposed to be fixed.
Any help?