pub struct StyleDocument { /* private fields */ }Expand description
A style document containing source registry, ordered layers, and optional terrain source.
Implementations§
Source§impl StyleDocument
impl StyleDocument
Sourcepub fn add_source(
&mut self,
id: impl Into<String>,
source: StyleSource,
) -> Result<(), StyleError>
pub fn add_source( &mut self, id: impl Into<String>, source: StyleSource, ) -> Result<(), StyleError>
Register a named source.
Sourcepub fn set_source(&mut self, id: impl Into<String>, source: StyleSource)
pub fn set_source(&mut self, id: impl Into<String>, source: StyleSource)
Upsert a named source.
Sourcepub fn remove_source(&mut self, id: &str) -> Option<StyleSource>
pub fn remove_source(&mut self, id: &str) -> Option<StyleSource>
Remove a source, returning it if present.
Sourcepub fn source(&self, id: &str) -> Option<&StyleSource>
pub fn source(&self, id: &str) -> Option<&StyleSource>
Look up a source by id.
Sourcepub fn sources(&self) -> impl Iterator<Item = (&str, &StyleSource)>
pub fn sources(&self) -> impl Iterator<Item = (&str, &StyleSource)>
Iterate registered sources.
Sourcepub fn set_terrain_source(&mut self, source_id: Option<impl Into<String>>)
pub fn set_terrain_source(&mut self, source_id: Option<impl Into<String>>)
Set the terrain source id used to configure MapState terrain.
Sourcepub fn terrain_source(&self) -> Option<&str>
pub fn terrain_source(&self) -> Option<&str>
Return the configured terrain source id, if any.
Sourcepub fn set_projection(&mut self, projection: StyleProjection)
pub fn set_projection(&mut self, projection: StyleProjection)
Set the top-level style projection.
Sourcepub fn projection(&self) -> StyleProjection
pub fn projection(&self) -> StyleProjection
Return the top-level style projection.
Sourcepub fn set_lights(&mut self, lights: Option<LightConfig>)
pub fn set_lights(&mut self, lights: Option<LightConfig>)
Set the lighting configuration.
Sourcepub fn lights(&self) -> Option<&LightConfig>
pub fn lights(&self) -> Option<&LightConfig>
Return the lighting configuration, if any.
Sourcepub fn set_transition(&mut self, spec: TransitionSpec)
pub fn set_transition(&mut self, spec: TransitionSpec)
Set the global default transition timing.
Sourcepub fn transition(&self) -> TransitionSpec
pub fn transition(&self) -> TransitionSpec
Return the global default transition timing.
Sourcepub fn add_layer(&mut self, layer: StyleLayer) -> Result<(), StyleError>
pub fn add_layer(&mut self, layer: StyleLayer) -> Result<(), StyleError>
Append a style layer to the ordered layer stack.
Sourcepub fn insert_layer_before(
&mut self,
before_id: &str,
layer: StyleLayer,
) -> Result<(), StyleError>
pub fn insert_layer_before( &mut self, before_id: &str, layer: StyleLayer, ) -> Result<(), StyleError>
Insert a style layer before another style layer id.
Sourcepub fn move_layer_before(&mut self, layer_id: &str, before_id: &str) -> bool
pub fn move_layer_before(&mut self, layer_id: &str, before_id: &str) -> bool
Move an existing style layer before another style layer.
Sourcepub fn remove_layer(&mut self, layer_id: &str) -> Option<StyleLayer>
pub fn remove_layer(&mut self, layer_id: &str) -> Option<StyleLayer>
Remove a style layer by id.
Sourcepub fn layer(&self, layer_id: &str) -> Option<&StyleLayer>
pub fn layer(&self, layer_id: &str) -> Option<&StyleLayer>
Get a style layer by id.
Sourcepub fn layer_mut(&mut self, layer_id: &str) -> Option<&mut StyleLayer>
pub fn layer_mut(&mut self, layer_id: &str) -> Option<&mut StyleLayer>
Get a mutable style layer by id.
Sourcepub fn layers(&self) -> &[StyleLayer]
pub fn layers(&self) -> &[StyleLayer]
Iterate style layers in render order.
Sourcepub fn to_runtime_layers(&self) -> Result<Vec<Box<dyn Layer>>, StyleError>
pub fn to_runtime_layers(&self) -> Result<Vec<Box<dyn Layer>>, StyleError>
Evaluate the style document to a concrete runtime layer stack.
Sourcepub fn to_runtime_layers_with_context(
&self,
ctx: StyleEvalContext,
) -> Result<Vec<Box<dyn Layer>>, StyleError>
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.
Sourcepub fn to_terrain_config(
&self,
) -> Result<Option<(TerrainConfig, usize)>, StyleError>
pub fn to_terrain_config( &self, ) -> Result<Option<(TerrainConfig, usize)>, StyleError>
Evaluate the configured terrain source to a concrete terrain config.
Sourcepub fn source_is_used(&self, source_id: &str) -> bool
pub fn source_is_used(&self, source_id: &str) -> bool
Return true if any style layer or terrain configuration uses the
given source id.
Sourcepub fn layer_ids_using_source(&self, source_id: &str) -> Vec<&str>
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.