Skip to main content

StyleDocument

Struct StyleDocument 

Source
pub struct StyleDocument { /* private fields */ }
Expand description

A style document containing source registry, ordered layers, and optional terrain source.

Implementations§

Source§

impl StyleDocument

Source

pub fn new() -> Self

Create an empty style document.

Source

pub fn add_source( &mut self, id: impl Into<String>, source: StyleSource, ) -> Result<(), StyleError>

Register a named source.

Source

pub fn set_source(&mut self, id: impl Into<String>, source: StyleSource)

Upsert a named source.

Source

pub fn remove_source(&mut self, id: &str) -> Option<StyleSource>

Remove a source, returning it if present.

Source

pub fn source(&self, id: &str) -> Option<&StyleSource>

Look up a source by id.

Source

pub fn sources(&self) -> impl Iterator<Item = (&str, &StyleSource)>

Iterate registered sources.

Source

pub fn set_terrain_source(&mut self, source_id: Option<impl Into<String>>)

Set the terrain source id used to configure MapState terrain.

Source

pub fn terrain_source(&self) -> Option<&str>

Return the configured terrain source id, if any.

Source

pub fn set_projection(&mut self, projection: StyleProjection)

Set the top-level style projection.

Source

pub fn projection(&self) -> StyleProjection

Return the top-level style projection.

Source

pub fn set_fog(&mut self, fog: Option<FogConfig>)

Set the fog/atmosphere configuration.

Source

pub fn fog(&self) -> Option<&FogConfig>

Return the fog/atmosphere configuration, if any.

Source

pub fn set_lights(&mut self, lights: Option<LightConfig>)

Set the lighting configuration.

Source

pub fn lights(&self) -> Option<&LightConfig>

Return the lighting configuration, if any.

Source

pub fn set_sky(&mut self, sky: Option<SkyConfig>)

Set the sky / atmosphere configuration.

Source

pub fn sky(&self) -> Option<&SkyConfig>

Return the sky / atmosphere configuration, if any.

Source

pub fn set_transition(&mut self, spec: TransitionSpec)

Set the global default transition timing.

Source

pub fn transition(&self) -> TransitionSpec

Return the global default transition timing.

Source

pub fn add_layer(&mut self, layer: StyleLayer) -> Result<(), StyleError>

Append a style layer to the ordered layer stack.

Source

pub fn insert_layer_before( &mut self, before_id: &str, layer: StyleLayer, ) -> Result<(), StyleError>

Insert a style layer before another style layer id.

Source

pub fn move_layer_before(&mut self, layer_id: &str, before_id: &str) -> bool

Move an existing style layer before another style layer.

Source

pub fn remove_layer(&mut self, layer_id: &str) -> Option<StyleLayer>

Remove a style layer by id.

Source

pub fn layer(&self, layer_id: &str) -> Option<&StyleLayer>

Get a style layer by id.

Source

pub fn layer_mut(&mut self, layer_id: &str) -> Option<&mut StyleLayer>

Get a mutable style layer by id.

Source

pub fn layers(&self) -> &[StyleLayer]

Iterate style layers in render order.

Source

pub fn to_runtime_layers(&self) -> Result<Vec<Box<dyn Layer>>, StyleError>

Evaluate the style document to a concrete runtime layer stack.

Source

pub fn to_runtime_layers_with_context( &self, ctx: StyleEvalContext, ) -> Result<Vec<Box<dyn Layer>>, StyleError>

Evaluate the style document to a concrete runtime layer stack using a context.

Source

pub fn to_terrain_config( &self, ) -> Result<Option<(TerrainConfig, usize)>, StyleError>

Evaluate the configured terrain source to a concrete terrain config.

Source

pub fn source_is_used(&self, source_id: &str) -> bool

Return true if any style layer or terrain configuration uses the given source id.

Source

pub fn layer_ids_using_source(&self, source_id: &str) -> Vec<&str>

Return the ordered list of style layer ids that reference the given source id.

Trait Implementations§

Source§

impl Debug for StyleDocument

Source§

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

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

impl Default for StyleDocument

Source§

fn default() -> StyleDocument

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> 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, 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.