Skip to main content

StyleValue

Type Alias StyleValue 

Source
pub type StyleValue<T> = Expression<T>;
Expand description

Type alias for backward compatibility.

StyleValue<T> is now an alias for [Expression<T>], the typed expression engine. All existing StyleValue::Constant(...), StyleValue::ZoomStops(...), and StyleValue::FeatureState { .. } constructions continue to work unchanged.

New code should prefer importing [Expression] directly and using the richer expression variants (GetProperty, Interpolate, Step, Match, Case, etc.) for data-driven styling.

Aliased Type§

pub enum StyleValue<T> {
    Constant(T),
    ZoomStops(Vec<(f32, T)>),
    FeatureState {
        key: String,
        fallback: T,
    },
    GetProperty {
        key: String,
        fallback: T,
    },
    Interpolate {
        input: Box<NumericExpression>,
        stops: Vec<(f32, T)>,
    },
    Step {
        input: Box<NumericExpression>,
        default: T,
        stops: Vec<(f32, T)>,
    },
    Match {
        input: Box<StringExpression>,
        cases: Vec<(String, T)>,
        fallback: T,
    },
    Case {
        branches: Vec<(BoolExpression, T)>,
        fallback: T,
    },
    Coalesce(Vec<Expression<T>>),
}

Variants§

§

Constant(T)

Constant literal value.

§

ZoomStops(Vec<(f32, T)>)

Zoom-keyed stops with linear interpolation.

§

FeatureState

Value driven by a per-feature state key.

Fields

§key: String

Feature-state key to look up (e.g. "hover", "selected").

§fallback: T

Default value when the key is absent.

§

GetProperty

Read a feature property and convert to T.

Equivalent to MapLibre ["get", "property_name"]. Falls back to fallback when the property is missing or cannot be converted to T.

Fields

§key: String

Property key to read from feature properties.

§fallback: T

Value to use when the property is absent or incompatible.

§

Interpolate

Interpolate between stops based on a numeric input expression.

Equivalent to MapLibre ["interpolate", ["linear"], input, z0, v0, z1, v1, ...].

Fields

§input: Box<NumericExpression>

The numeric input value (typically Expression::Zoom or a property).

§stops: Vec<(f32, T)>

Ordered stop pairs (input_value, output_value).

§

Step

Step function: returns the stop value for the greatest stop ≤ input.

Equivalent to MapLibre ["step", input, default, z0, v0, z1, v1, ...].

Fields

§input: Box<NumericExpression>

The numeric input.

§default: T

Default value when input is below all stops.

§stops: Vec<(f32, T)>

Ordered stops (threshold, output_value).

§

Match

Pattern match on a string input expression.

Equivalent to MapLibre ["match", input, label1, val1, ..., fallback].

Fields

§input: Box<StringExpression>

The string input to match against.

§cases: Vec<(String, T)>

Cases: (label, output_value).

§fallback: T

Value when no case matches.

§

Case

Conditional branches evaluated in order.

Equivalent to MapLibre ["case", cond1, val1, cond2, val2, ..., fallback].

Fields

§branches: Vec<(BoolExpression, T)>

Branches: (condition, output_value).

§fallback: T

Value when no condition is true.

§

Coalesce(Vec<Expression<T>>)

Return the first non-null result from a list of expressions.

Equivalent to MapLibre ["coalesce", expr1, expr2, ...].