pub trait Layer: MaybeSend + MaybeSync {
// Required methods
fn render(&self, view: &MapView, canvas: &mut dyn Canvas);
fn prepare(&self, view: &MapView);
fn set_messenger(&mut self, messenger: Box<dyn Messenger>);
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
}
Expand description
Layers specify a data source and the way the data should be rendered to the map.
There are currently 3 types of layers:
RasterTileLayer
- downloads prerendered tiles from an Internet source and draws them as is.VectorTileLayer
- downloads vector tiles (in MVT format) from an Internet source and draws them using the provided stylesheet.FeatureLayer
- draws custom set of geographic objects with the givenfeature_layer::Symbol
;
Required Methods§
sourcefn render(&self, view: &MapView, canvas: &mut dyn Canvas)
fn render(&self, view: &MapView, canvas: &mut dyn Canvas)
Renders the layer to the given canvas.
sourcefn prepare(&self, view: &MapView)
fn prepare(&self, view: &MapView)
Prepares the layer for rendering with the given view
. The preparation may include data downloading, decoding
or other asynchronous operations which cannot be awaited for during render cycle..
sourcefn set_messenger(&mut self, messenger: Box<dyn Messenger>)
fn set_messenger(&mut self, messenger: Box<dyn Messenger>)
Sets the messenger for the layer. Messenger is used to notify the application when the layer thinks it should be updated on the screen.
sourcefn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
A map stores layers as trait objects. This method can be used to convert the trait object into the concrete type.
sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
A map stores layers as trait objects. This method can be used to convert the trait object into the concrete type.