Package-level declarations

The Kotlin DSL for creating MapLibre expressions. This is the primary API you'll be using to create expressions.

Types

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
object Feature

Object to access feature-related data, see feature

Link copied to clipboard
data class FormatSpan

Represents a component of a format expression. See span.

Link copied to clipboard

Represents a variable bound with withVariable. Reference the bound expression with use.

Properties

Link copied to clipboard

Converts a numeric Expression to a DpValue expression.

Link copied to clipboard

Returns the mathematical constant e

Link copied to clipboard

Converts a numeric Expression to an TextUnitValue expression in EM

Link copied to clipboard

Accesses to feature-related data

Link copied to clipboard

Returns mathematical constant ln(2) = natural logarithm of 2.

Link copied to clipboard

Converts a numeric Expression in milliseconds to a MillisecondsValue expression.

Link copied to clipboard

Returns the mathematical constant π

Link copied to clipboard

Converts a numeric Expression in seconds to a MillisecondsValue expression.

Link copied to clipboard

Converts a numeric Expression to an TextUnitValue expression in SP.

Functions

Link copied to clipboard
fun <U, V : NumberValue<U>> abs(value: Expression<V>): Expression<V>

Returns the absolute value of value, i.e. always a positive value.

Link copied to clipboard

Returns the arccosine of value.

Link copied to clipboard
fun all(vararg expressions: Expression<BooleanValue>): Expression<BooleanValue>

Returns whether all expressions are true.

Link copied to clipboard

Returns whether both this and other expressions are true.

Link copied to clipboard
fun any(vararg expressions: Expression<BooleanValue>): Expression<BooleanValue>

Returns whether any expressions are true.

Link copied to clipboard
fun Expression<*>.asBoolean(vararg fallbacks: Expression<*>): Expression<BooleanValue>

Asserts that this value is a boolean.

Link copied to clipboard

Asserts that this is a list of numbers of length 2.

Link copied to clipboard
inline fun <T : Enum<T>, EnumValue<T>> Expression<*>.asEnum(vararg fallbacks: Expression<*>): Expression<T>

Asserts that this value is an entry of the enum specified by T.

Link copied to clipboard

Returns the arcsine of value.

Link copied to clipboard
fun Expression<*>.asList(type: Expression<ExpressionType> = nil(), length: Expression<IntValue> = nil()): Expression<ListValue<*>>

Asserts that this is a list (optionally with a specific item type and length).

Link copied to clipboard
fun Expression<*>.asMap(vararg fallbacks: Expression<*>): Expression<MapValue<*>>

Asserts that this value is a map.

Link copied to clipboard
fun Expression<*>.asNumber(vararg fallbacks: Expression<*>): Expression<FloatValue>

Asserts that this value is a number.

Link copied to clipboard

Asserts that this is a list of numbers of length 2.

Link copied to clipboard

Asserts that this is a list of numbers of length 4.

Link copied to clipboard
fun Expression<*>.asString(vararg fallbacks: Expression<*>): Expression<StringValue>

Asserts that this value is a string.

Link copied to clipboard
fun <U, V : NumberValue<U>> Expression<*>.asVector(length: Expression<IntValue> = nil()): Expression<V>

Asserts that this is a list of numbers, optionally with a specific length.

Link copied to clipboard

Returns the arctangent of value.

Link copied to clipboard
fun <O : ExpressionValue> case(label: Number, output: Expression<O>): Case<FloatValue, O>
fun <O : ExpressionValue> case(label: String, output: Expression<O>): Case<StringValue, O>
@JvmName(name = "numbersCase")
fun <O : ExpressionValue> case(label: List<Number>, output: Expression<O>): Case<FloatValue, O>
@JvmName(name = "stringsCase")
fun <O : ExpressionValue> case(label: List<String>, output: Expression<O>): Case<StringValue, O>

Create a Case, see switch

Link copied to clipboard

Returns the smallest integer that is greater than or equal to value.

Link copied to clipboard
fun <T : ExpressionValue> coalesce(vararg values: Expression<T>): Expression<T>

Evaluates each expression in values in turn until the first non-null value is obtained, and returns that value.

Link copied to clipboard
fun collator(caseSensitive: Expression<BooleanValue>? = null, diacriticSensitive: Expression<BooleanValue>? = null, locale: Expression<StringValue>? = null): Expression<CollatorValue>
fun collator(caseSensitive: Boolean? = null, diacriticSensitive: Boolean? = null, locale: String? = null): Expression<CollatorValue>

Returns a collator for use in locale-dependent comparison operations. The caseSensitive and diacriticSensitive options default to false. The locale argument specifies the IETF language tag of the locale to use. If none is provided, the default locale is used. If the requested locale is not available, the collator will use a system-defined fallback locale. Use resolvedLocale to test the results of locale fallback behavior.

Link copied to clipboard
Link copied to clipboard
fun <T : EnumValue<T>> const(value: T): EnumLiteral<T>

Creates a literal expression for an enum value implementing EnumValue.

Creates a literal expression for a PaddingValues.Absolute value.

fun const(offset: Offset): OffsetLiteral

Creates a literal expression for an Offset value.

fun const(color: Color): ColorLiteral

Creates a literal expression for a Color value.

fun const(dp: Dp): DpLiteral

Creates a literal expression for a Dp value.

Creates a literal expression for a DpOffset value.

Creates a literal expression for a specified TextUnit value in SP or EM. It can be provided in either unit, and will resolve to one at runtime depending on the property it is used in.

Creates a literal expression for a Boolean value.

fun const(float: Float): FloatLiteral

Creates a literal expression for a dimensionless Float value.

fun const(int: Int): IntLiteral

Creates a literal expression for an dimensionless Int value.

fun const(string: String): StringLiteral

Creates a literal expression for a String value.

Creates a literal expression for a list.

@JvmName(name = "constNumberList")
fun const(list: List<Number>): Literal<VectorValue<Number>, *>

Creates a literal expression for a list of numbers.

@JvmName(name = "constStringList")
fun const(list: List<String>): ListLiteral<StringValue>

Creates a literal expression for a list of strings.

Creates a literal expression for a Duration value.

Link copied to clipboard

Returns whether this list contains the item.

@JvmName(name = "containsString")
fun Expression<StringValue>.contains(substring: String): Expression<BooleanValue>
@JvmName(name = "containsString")
fun String.contains(substring: Expression<StringValue>): Expression<BooleanValue>

Returns whether this string contains the substring.

Link copied to clipboard

Converts this expression to a boolean expression.

Link copied to clipboard

Converts this expression to a color expression.

Link copied to clipboard

Converts this expression to a number.

Link copied to clipboard

Converts this expression to a string.

Link copied to clipboard

Returns the cosine of value.

Link copied to clipboard

Interpolates using the cubic bezier curve defined by the given control points between the pairs of stops.

Link copied to clipboard

Returns the shortest distance in meters between the evaluated feature and geometry.

Link copied to clipboard
@JvmName(name = "divUnitBoth")
operator fun <U, V : NumberValue<U>> Expression<V>.div(divisor: Expression<V>): Expression<FloatValue>
@JvmName(name = "divUnitLeftOnly")
operator fun <U, V : NumberValue<U>> Expression<V>.div(divisor: Expression<FloatValue>): Expression<V>

Returns the result of floating point division of this number expression by divisor.

Link copied to clipboard

Returns whether the left string expression is equal to the right string expression. An optional collator (see collator function) can be specified to control locale-dependent string comparisons.

Link copied to clipboard

Returns whether this expression is equal to other.

Link copied to clipboard

Interpolates exponentially between the stops.

Link copied to clipboard

Returns the largest integer that is less than or equal to value.

Link copied to clipboard

Returns a formatted string for displaying mixed-format text in the textField property (see dev.sargunv.maplibrecompose.compose.layer.SymbolLayer). The input may contain a string literal or expression, including an image expression.

Link copied to clipboard
fun Expression<NumberValue<*>>.formatToString(locale: Expression<StringValue>? = null, currency: Expression<StringValue>? = null, minFractionDigits: Expression<IntValue>? = null, maxFractionDigits: Expression<IntValue>? = null): Expression<StringValue>
fun Expression<NumberValue<*>>.formatToString(locale: String? = null, currency: String? = null, minFractionDigits: Int? = null, maxFractionDigits: Int? = null): Expression<StringValue>

Converts this number into a string representation using the provided formatting rules.

Link copied to clipboard
@JvmName(name = "getAt")
operator fun <T : ExpressionValue> Expression<ListValue<T>>.get(index: Expression<IntValue>): Expression<T>
@JvmName(name = "getAt")
operator fun <T : ExpressionValue> Expression<ListValue<T>>.get(index: Int): Expression<T>

Returns the item at index.

Returns the value corresponding the given key or null if it is not present in this map.

Link copied to clipboard

Returns whether the left string expression is strictly greater than the right string expression. An optional collator (see collator) can be specified to control locale-dependent string comparisons.

Link copied to clipboard

Returns whether this expression is strictly greater than other.

Link copied to clipboard

Returns whether the left string expression is greater than or equal to the right string expression. An optional collator (see collator) can be specified to control locale-dependent string comparisons.

Link copied to clipboard

Returns whether this expression is greater than or equal to other.

Link copied to clipboard

Returns whether the given key is in this map.

Link copied to clipboard

Gets the kernel density estimation of a pixel in a heatmap layer, which is a relative measure of how many data points are crowded around a particular pixel. Can only be used in the expression for the color parameter in a HeatmapLayer dev.sargunv.maplibrecompose.compose.layer.HeatmapLayer.

Link copied to clipboard
fun image(value: ImageBitmap, sdf: Boolean = false): Expression<ImageValue>
fun image(value: Painter, size: DpSize? = null, sdf: Boolean = false): Expression<ImageValue>

Returns an image type for use in iconImage (see dev.sargunv.maplibrecompose.compose.layer.SymbolLayer), pattern entries (see dev.sargunv.maplibrecompose.compose.layer.BackgroundLayer, dev.sargunv.maplibrecompose.compose.layer.FillLayer, dev.sargunv.maplibrecompose.compose.layer.FillExtrusionLayer, dev.sargunv.maplibrecompose.compose.layer.LineLayer) and as a section in the format expression.

Link copied to clipboard
@JvmName(name = "indexOfList")
fun <T : ExpressionValue> Expression<ListValue<T>>.indexOf(item: Expression<T>, startIndex: Expression<IntValue>? = null): Expression<IntValue>
@JvmName(name = "indexOfList")
fun <T : ExpressionValue> Expression<ListValue<T>>.indexOf(item: Expression<T>, startIndex: Int? = null): Expression<IntValue>

Returns the first index at which the item is located in this list, or -1 if it cannot be found. Accepts an optional startIndex from where to begin the search.

@JvmName(name = "indexOfString")
fun Expression<StringValue>.indexOf(substring: Expression<StringValue>, startIndex: Expression<IntValue>? = null): Expression<IntValue>
@JvmName(name = "indexOfString")
fun Expression<StringValue>.indexOf(substring: String, startIndex: Int? = null): Expression<IntValue>
@JvmName(name = "indexOfString")
fun String.indexOf(substring: Expression<StringValue>, startIndex: Expression<IntValue>? = null): Expression<IntValue>

Returns the first index at which the substring is located in this string, or -1 if it cannot be found. Accepts an optional startIndex from where to begin the search.

Link copied to clipboard

Produces continuous, smooth results by interpolating between pairs of input and output values (stops), given the input value.

Link copied to clipboard

Produces continuous, smooth results by interpolating between pairs of input and output values (stops), given the input value. Works like interpolate, but the interpolation is performed in the Hue-Chroma-Luminance color space.

Link copied to clipboard

Produces continuous, smooth results by interpolating between pairs of input and output values (stops), given the input value. Works like interpolate, but the interpolation is performed in the CIELAB color space.

Link copied to clipboard

Returns true if this string is expected to render legibly. Returns false if this string contains sections that cannot be rendered without potential loss of meaning (e.g. Indic scripts that require complex text shaping).

Link copied to clipboard
@JvmName(name = "lengthOfList")
fun Expression<ListValue<*>>.length(): Expression<IntValue>

Gets the length of a this list.

@JvmName(name = "lengthOfString")
fun Expression<StringValue>.length(): Expression<IntValue>

Gets the length of this string.

Link copied to clipboard

Interpolates linearly between the pairs of stops.

Link copied to clipboard

Returns the natural logarithm of value.

Link copied to clipboard

Returns the base-ten logarithm of value.

Link copied to clipboard

Returns the base-two logarithm of value.

Link copied to clipboard

Returns this string converted to lowercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.

Link copied to clipboard

Returns whether the left string expression is strictly less than the right string expression. An optional collator (see collator) can be specified to control locale-dependent string comparisons.

Link copied to clipboard

Returns whether this expression is strictly less than other.

Link copied to clipboard

Returns whether the left string expression is less than or equal to the right string expression. An optional collator (see collator) can be specified to control locale-dependent string comparisons.

Link copied to clipboard

Returns whether this string expression is less than or equal to other.

Link copied to clipboard
fun <U, V : NumberValue<U>> max(vararg numbers: Expression<V>): Expression<V>

Returns the greatest of all given numbers.

Link copied to clipboard
fun <U, V : NumberValue<U>> min(vararg numbers: Expression<V>): Expression<V>

Returns the smallest of all given numbers.

Link copied to clipboard
operator fun <U, V : NumberValue<U>> Expression<V>.minus(other: Expression<NumberValue<U>>): Expression<V>

Returns the result of subtracting other from this number expression.

Link copied to clipboard

Returns whether the left string expression is not equal to the right string expression. An optional collator (see collator) can be specified to control locale-dependent string comparisons.

Link copied to clipboard

Returns whether this expression is not equal to other.

Link copied to clipboard

Creates a literal expression for a null value.

Link copied to clipboard
@JvmName(name = "notOperator")
operator fun Expression<BooleanValue>.not(): Expression<BooleanValue>

Negates this expression.

Link copied to clipboard

Creates a literal expression for a 2D DpOffset.

Creates a literal expression for a 2D TextUnit offset.

Creates a literal expression for a 2D Offset.

Link copied to clipboard

Returns whether any of this or the other expressions are true.

Link copied to clipboard
operator fun <U, V : NumberValue<U>> Expression<V>.plus(other: Expression<V>): Expression<V>

Returns the sum of this number expression with other.

Concatenates this string expression with other.

Link copied to clipboard

Returns the result of raising this number expression to the power of exponent.

Link copied to clipboard
operator fun <U, V : NumberValue<U>> Expression<V>.rem(divisor: Expression<IntValue>): Expression<V>

Returns the remainder after integer division of this number expression by divisor.

Link copied to clipboard

Returns the IETF language tag of the locale being used by the provided collator. This can be used to determine the default system locale, or to determine if a requested locale was successfully loaded.

Link copied to clipboard

Creates a color value from red, green, and blue components, which must range between 0 and 255, and optionally an alpha component which must range between 0 and 1.

Link copied to clipboard

Rounds value to the nearest integer. Halfway values are rounded away from zero.

Link copied to clipboard

Returns the sine of value.

Link copied to clipboard
fun <T : ExpressionValue> Expression<ListValue<T>>.slice(startIndex: Int, endIndex: Int? = null): Expression<ListValue<T>>

Returns the items in this list from the startIndex (inclusive) to the end of this list if endIndex is not specified or null, otherwise to endIndex (exclusive).

Link copied to clipboard

Configures an image in a format expression.

fun span(value: Expression<StringValue>, textFont: Expression<StringValue>? = null, textColor: Expression<ColorValue>? = null, textSize: Expression<TextUnitValue>? = null): FormatSpan
fun span(value: String, textFont: String? = null, textColor: Color? = null, textSize: TextUnit? = null): FormatSpan

Configures a span of text in a format expression.

Link copied to clipboard

Returns the square root of value.

Link copied to clipboard
fun <T : ExpressionValue> step(input: Expression<FloatValue>, fallback: Expression<T>, vararg stops: Pair<Number, Expression<T>>): Expression<T>

Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (stops). Returns the output value of the stop just less than the input, or the fallback if the input is less than the first stop.

Link copied to clipboard
fun Expression<StringValue>.substring(startIndex: Int, endIndex: Int? = null): Expression<StringValue>

Returns a substring from this string from the startIndex (inclusive) to the end of the string if endIndex is not specified or null, otherwise to endIndex (exclusive).

Link copied to clipboard
fun <T : ExpressionValue> switch(vararg conditions: Condition<T>, fallback: Expression<T>): Expression<T>

Selects the first output from the given conditions whose corresponding test condition evaluates to true, or the fallback value otherwise.

fun <I : MatchableValue, O : ExpressionValue> switch(input: Expression<I>, vararg cases: Case<I, O>, fallback: Expression<O>): Expression<O>

Selects the output from the given cases whose label value matches the input, or the fallback value if no match is found.

Link copied to clipboard

Returns the tangent of value.

Link copied to clipboard

Creates a literal expression for TextVariableAnchorOffsetValue, used by dev.sargunv.maplibrecompose.compose.layer.SymbolLayer's textVariableAnchorOffset parameter.

Link copied to clipboard
@JvmName(name = "timesUnitLeft")
operator fun <U, V : NumberValue<U>> Expression<V>.times(other: Expression<FloatValue>): Expression<V>
@JvmName(name = "timesUnitRight")
operator fun <U, V : NumberValue<U>> Expression<FloatValue>.times(other: Expression<V>): Expression<V>

Returns the product of this number expression with other.

Link copied to clipboard

Returns a four-element list, containing the color's red, green, blue, and alpha components, in that order.

Link copied to clipboard

Returns a string describing the type of this expression.

Link copied to clipboard
operator fun <U, V : NumberValue<U>> Expression<V>.unaryMinus(): Expression<V>

Negates this number expression.

Link copied to clipboard

Returns this string converted to uppercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.

Link copied to clipboard

References a Variable bound in withVariable.

Link copied to clipboard

Returns true if the evaluated feature is fully contained inside a boundary of the input geometry, false otherwise. The input value can be a valid GeoJSON of type Polygon, MultiPolygon, Feature, or FeatureCollection. Supported features for evaluation:

Link copied to clipboard
inline fun <V : ExpressionValue, R : ExpressionValue> withVariable(name: String, value: Expression<V>, block: (Variable<V>) -> Expression<R>): Expression<R>

Binds expression value to a Variable with the given name, which can then be referenced inside the block using use. For example:

Link copied to clipboard

Gets the current zoom level. Note that in layer style properties, zoom may only appear as the input to a top-level step or interpolate (, interpolateHcl, interpolateLab, ...) expression.