Skip to main content

VectorStyle

Struct VectorStyle 

Source
pub struct VectorStyle {
Show 54 fields pub render_mode: VectorRenderMode, pub fill_color: [f32; 4], pub stroke_color: [f32; 4], pub stroke_width: f32, pub point_radius: f32, pub line_cap: LineCap, pub line_join: LineJoin, pub miter_limit: f32, pub dash_array: Option<Vec<f32>>, pub heatmap_radius: f32, pub heatmap_intensity: f32, pub extrusion_base: f32, pub extrusion_height: f32, pub symbol_size: f32, pub symbol_halo_color: [f32; 4], pub symbol_text_field: Option<String>, pub symbol_icon_image: Option<String>, pub symbol_font_stack: String, pub symbol_padding: f32, pub symbol_allow_overlap: bool, pub symbol_text_allow_overlap: bool, pub symbol_icon_allow_overlap: bool, pub symbol_text_optional: bool, pub symbol_icon_optional: bool, pub symbol_text_ignore_placement: bool, pub symbol_icon_ignore_placement: bool, pub symbol_text_anchor: SymbolAnchor, pub symbol_text_justify: SymbolTextJustify, pub symbol_text_transform: SymbolTextTransform, pub symbol_text_max_width: Option<f32>, pub symbol_text_line_height: Option<f32>, pub symbol_text_letter_spacing: Option<f32>, pub symbol_icon_text_fit: SymbolIconTextFit, pub symbol_icon_text_fit_padding: [f32; 4], pub symbol_sort_key: Option<f32>, pub symbol_anchors: Vec<SymbolAnchor>, pub symbol_placement: SymbolPlacement, pub symbol_spacing: f32, pub symbol_max_angle: f32, pub symbol_keep_upright: bool, pub symbol_text_radial_offset: Option<f32>, pub symbol_variable_anchor_offsets: Option<Vec<(SymbolAnchor, [f32; 2])>>, pub symbol_writing_mode: SymbolWritingMode, pub symbol_offset: [f32; 2], pub fill_translate: [f32; 2], pub fill_opacity: f32, pub fill_antialias: bool, pub fill_outline_color: Option<[f32; 4]>, pub fill_pattern: Option<Arc<PatternImage>>, pub line_pattern: Option<Arc<PatternImage>>, pub width_expr: Option<Expression<f32>>, pub stroke_color_expr: Option<Expression<[f32; 4]>>, pub eval_zoom: f32, pub line_gradient: Option<ColorRamp>,
}
Expand description

Style parameters for rendering a vector layer.

Fields§

§render_mode: VectorRenderMode

Active render family.

§fill_color: [f32; 4]

Fill colour (RGBA, 0–1 range).

§stroke_color: [f32; 4]

Stroke (outline) colour (RGBA, 0–1 range).

§stroke_width: f32

Stroke width in pixels.

§point_radius: f32

Point/circle radius in pixels.

§line_cap: LineCap

Line cap style.

§line_join: LineJoin

Line join style.

§miter_limit: f32

Miter limit ratio — when the miter length exceeds miter_limit * stroke_width, a miter join falls back to bevel. Default 2.0 (matching MapLibre / Mapbox).

§dash_array: Option<Vec<f32>>

Optional dash pattern [dash_length, gap_length, …] in pixels.

§heatmap_radius: f32

Heatmap radius in pixels.

§heatmap_intensity: f32

Heatmap intensity multiplier.

§extrusion_base: f32

Extrusion base height in meters.

§extrusion_height: f32

Extrusion height in meters.

§symbol_size: f32

Symbol size in pixels.

§symbol_halo_color: [f32; 4]

Symbol halo colour.

§symbol_text_field: Option<String>

Feature property used for text labels.

§symbol_icon_image: Option<String>

Optional icon image id for point symbols.

§symbol_font_stack: String

Font stack used for glyph dependency requests.

§symbol_padding: f32

Collision padding in pixels.

§symbol_allow_overlap: bool

Shared overlap fallback for simplified callers.

Mapbox and MapLibre distinguish text and icon overlap flags. The engine keeps this field as a shared default for existing call sites, while the more specific text/icon flags below let symbol candidates apply closer spec behavior.

§symbol_text_allow_overlap: bool

Whether text is allowed to overlap other placed symbols.

§symbol_icon_allow_overlap: bool

Whether icons are allowed to overlap other placed symbols.

§symbol_text_optional: bool

Whether text may be dropped while keeping the icon.

§symbol_icon_optional: bool

Whether the icon may be dropped while keeping the text.

§symbol_text_ignore_placement: bool

Whether text may be placed without blocking later symbols.

§symbol_icon_ignore_placement: bool

Whether icons may be placed without blocking later symbols.

§symbol_text_anchor: SymbolAnchor

Default anchor when variable anchors are not in use.

§symbol_text_justify: SymbolTextJustify

Effective horizontal justification for the current label.

§symbol_text_transform: SymbolTextTransform

Text transformation applied before measurement and placement.

§symbol_text_max_width: Option<f32>

Maximum point-label width in symbol-size units before wrapping.

This is the engine’s simplified text-max-width representation. It is currently used to estimate wrapped placeholder text boxes for point labels, which improves collision and sizing behavior before full glyph shaping is in place.

§symbol_text_line_height: Option<f32>

Preferred line height for wrapped text in text-size units.

The engine uses this in its simplified wrapped text-box estimate so placeholder label height follows the style more closely even before full glyph shaping is implemented.

§symbol_text_letter_spacing: Option<f32>

Extra spacing between adjacent glyphs in text-size units.

The engine applies this to its placeholder text width estimate so label collisions and wrapping react to text-letter-spacing before full glyph shaping exists.

§symbol_icon_text_fit: SymbolIconTextFit

Icon sizing mode relative to label text.

§symbol_icon_text_fit_padding: [f32; 4]

Padding applied when fitting the icon around text.

§symbol_sort_key: Option<f32>

Placement priority for symbol ordering.

Lower sort keys are placed first, matching Mapbox and MapLibre’s symbol-sort-key semantics. None preserves source order when the style does not request explicit symbol ordering.

§symbol_anchors: Vec<SymbolAnchor>

Preferred variable anchors in priority order.

§symbol_placement: SymbolPlacement

Whether symbols are anchored on points or along lines.

§symbol_spacing: f32

Preferred spacing between repeated line-placed symbols in pixels.

Mapbox and MapLibre interpret this during tile-space symbol layout. The engine currently uses it as an approximate world-space spacing for repeated line anchors until full line-shaped symbol layout is in place.

§symbol_max_angle: f32

Maximum cumulative turn angle tolerated for a line-placed label.

The current implementation applies this as a simplified readability check over the retained line window around each anchor. It is not yet a full reproduction of Mapbox or MapLibre’s sliding-window angle logic, but it prevents labels from being emitted on the sharpest bends.

§symbol_keep_upright: bool

Whether line-placed text should be flipped to remain upright.

Mapbox and MapLibre use this to avoid upside-down line labels. The engine currently applies it by normalizing line-anchor rotation into an upright range before placement.

§symbol_text_radial_offset: Option<f32>

Radial text offset measured in symbol-size units.

The full style spec defines this in EM-like text units. The engine uses the current symbol size as the scale factor so anchored labels can move outward in the requested direction without waiting for full glyph shaping metrics.

§symbol_variable_anchor_offsets: Option<Vec<(SymbolAnchor, [f32; 2])>>

Explicit per-anchor offsets for variable anchor placement.

This is the engine’s simplified representation of text-variable-anchor-offset. Values are stored in symbol-size units and resolved for the selected anchor during placement.

§symbol_writing_mode: SymbolWritingMode

Writing mode for symbol text.

§symbol_offset: [f32; 2]

Pixel-space symbol offset.

§fill_translate: [f32; 2]

Fill-layer pixel translate offset [tx, ty].

§fill_opacity: f32

Fill-layer opacity (separate from vertex alpha).

§fill_antialias: bool

Whether fill edges should be antialiased.

§fill_outline_color: Option<[f32; 4]>

Optional distinct outline color. When None, outline uses stroke_color.

§fill_pattern: Option<Arc<PatternImage>>

Optional fill pattern image.

When set, the fill is rendered with a repeating pattern texture instead of a solid colour. The pattern repeats in world space with one pattern pixel mapping to approximately one meter, matching MapLibre / Mapbox fill-pattern semantics.

§line_pattern: Option<Arc<PatternImage>>

Optional line pattern image.

When set, the line is rendered with a repeating pattern texture instead of a solid colour. The pattern maps along the line centreline (U axis, distance / pattern width) and across the line width (V axis, 0 at left edge → 1 at right edge), matching MapLibre / Mapbox line-pattern semantics.

§width_expr: Option<Expression<f32>>

Optional data-driven width expression.

When present and Expression::is_data_driven returns true, VectorLayer::tessellate evaluates the expression per feature instead of using the single stroke_width value for every feature.

§stroke_color_expr: Option<Expression<[f32; 4]>>

Optional data-driven stroke-color expression.

Same semantics as width_expr: when data-driven, colour is resolved per feature during tessellation.

§eval_zoom: f32

Zoom level captured at style-evaluation time.

Needed to build a per-feature ExprEvalContext during tessellation so that zoom-dependent stops still resolve correctly.

§line_gradient: Option<ColorRamp>

Optional colour ramp evaluated along the polyline centreline.

When set, the tessellator overrides per-vertex colours with the gradient evaluated at each vertex’s normalized distance [0, 1] along the feature. This replicates MapLibre / Mapbox’s line-gradient property.

Implementations§

Source§

impl VectorStyle

Source

pub fn fill( fill_color: [f32; 4], outline_color: [f32; 4], outline_width: f32, ) -> Self

Convenience constructor for fill rendering.

Source

pub fn fill_pattern(pattern: Arc<PatternImage>) -> Self

Fill rendering with a repeating pattern texture.

The pattern overrides fill_color — the fragment shader samples the pattern image instead of using a solid colour.

Source

pub fn line_pattern(width: f32, pattern: Arc<PatternImage>) -> Self

Line rendering with a repeating pattern texture.

The pattern maps along the line centreline and across its width. The fragment shader samples the pattern image instead of using a solid colour, matching MapLibre / Mapbox line-pattern semantics.

Source

pub fn line(color: [f32; 4], width: f32) -> Self

Convenience constructor for line rendering.

Source

pub fn line_styled( color: [f32; 4], width: f32, cap: LineCap, join: LineJoin, miter_limit: f32, dash_array: Option<Vec<f32>>, ) -> Self

Line rendering with explicit cap, join, and miter limit.

Source

pub fn line_gradient(width: f32, ramp: ColorRamp) -> Self

Line rendering with a colour gradient along the polyline.

The gradient overrides color — per-vertex colours are computed from the ColorRamp at each vertex’s normalised distance along the line.

Source

pub fn circle( color: [f32; 4], radius: f32, stroke_color: [f32; 4], stroke_width: f32, ) -> Self

Convenience constructor for point circles.

Source

pub fn heatmap(color: [f32; 4], radius: f32, intensity: f32) -> Self

Convenience constructor for heatmap blobs.

Source

pub fn fill_extrusion(color: [f32; 4], base: f32, height: f32) -> Self

Convenience constructor for polygon extrusion.

Source

pub fn symbol(color: [f32; 4], halo_color: [f32; 4], size: f32) -> Self

Convenience constructor for basic symbol markers.

Source

pub fn tessellation_fingerprint(&self) -> u64

Compute a lightweight u64 fingerprint of the fields that affect VectorLayer::tessellate output.

Two styles that produce identical tessellation results will have the same fingerprint. The hash is cheap (a few dozen field reads through the default hasher) and is used by the sync-path vector bucket cache to detect style changes without requiring PartialEq on VectorStyle.

Source

pub fn is_width_data_driven(&self) -> bool

Whether line width is data-driven (varies per feature).

Source

pub fn is_stroke_color_data_driven(&self) -> bool

Whether stroke color is data-driven (varies per feature).

Source

pub fn evaluate_width(&self, feature: &Feature) -> f32

Evaluate stroke width for a specific feature’s properties.

Returns self.stroke_width when no data-driven expression is set.

Source

pub fn evaluate_stroke_color(&self, feature: &Feature) -> [f32; 4]

Evaluate stroke color for a specific feature’s properties.

Returns self.stroke_color when no data-driven expression is set.

Trait Implementations§

Source§

impl Clone for VectorStyle

Source§

fn clone(&self) -> VectorStyle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VectorStyle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VectorStyle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.