Table of Contents

Class StyleExpressionHandle

Namespace
Maplibre.NativeFfi
Assembly
Maplibre.NativeFfi.dll

A parsed style expression.

public sealed class StyleExpressionHandle : IDisposable
Inheritance
StyleExpressionHandle
Implements
Inherited Members

Remarks

See mln_style_expression in the C API reference.

Properties

Id

The native handle value. It stays readable after release.

public ulong Id { get; }

Property Value

ulong

IsClosed

Whether a release, dispose, or discard has ended the handle.

public bool IsClosed { get; }

Property Value

bool

Methods

Create(string, StyleExpressionOptions?)

Parses a style expression to evaluate without a map.

public static StyleExpressionHandle Create(string expression, StyleExpressionOptions? options = null)

Parameters

expression string
options StyleExpressionOptions

Returns

StyleExpressionHandle

Remarks

See mln_style_expression_create in the C API reference.

Errors:

  • Status.InvalidArgument when expression isn't a valid expression, or its result can't have the expected type.

Evaluate(StyleExpressionInputs?)

Evaluates a style expression and writes its result as JSON.

public string Evaluate(StyleExpressionInputs? inputs = null)

Parameters

inputs StyleExpressionInputs

Returns

string

Remarks

A number in the result that isn't finite becomes null. A color is ["rgba", r, g, b, a], with red, green, and blue from 0 to 255 and alpha from 0 to 1, each exact only to single precision. Formatted text is a ["format", …] expression, an image is {"name": …, "available": …}, padding is [top, right, bottom, left], and a variable anchor offset is [anchor, [x, y], …].

See mln_style_expression_evaluate in the C API reference.

Errors:

  • Status.InvalidArgument when the expression fails to evaluate, such as when it reads an input that inputs doesn't set.

GetInfo()

Reads what a style expression's result depends on.

public StyleExpressionInfo GetInfo()

Returns

StyleExpressionInfo

Remarks

See mln_style_expression_get_info in the C API reference.

Release()

Releases a parsed style expression.

public void Release()

Remarks

See mln_style_expression_release in the C API reference.

ToString()

Names the handle's type, its Id, and whether it is closed.

public override string ToString()

Returns

string