androidkotlinmapboxmapbox-android

Migrating Expression.inExpression with kotlin.IntArray from Mapbox Android v9 to v10


I'm migrating an app from v9 of the Mapbox Android SDK to v10, and I'm running into an issue trying to update some code we're using to filter a layer's features using a Kotlin IntArray.

This worked for us in Mapbox Android v9: Expression.inExpression(Expression.get("id"), Expression.literal(intArray))

However, after updating the SDK to v10 I get an error: "None of the following functions can be called with the arguments supplied." It looks like Expression.literal supports passing a List<Any> in, but the function is marked internal. I think going with Expression.ExpressionBuilder may work, but I'm kind of flying blind and can't find any documentation on this.

How do I migrate this line of code to Mapbox v10?

Expression.inExpression(Expression.get("id"), Expression.literal(intArray))


Solution

  • I was able to accomplish the same functionality in v10 by passing an Expression.ExpressionBuilder block to Expression.inExpression:

    Expression.inExpression {
      get("id")
      literal(ids)
    }