pub struct Basemap { /* private fields */ }Expand description
A map view: one style, or several stacked bottom to top, a size in CSS
pixels, a centre and MapLibre zoom (512 px tiles, fractional allowed),
and a device pixel ratio (images are pixel_ratio times larger with the
same view and label layout).
Implementations§
Source§impl Basemap
impl Basemap
Sourcepub fn new(style: impl Into<String>) -> Self
pub fn new(style: impl Into<String>) -> Self
A view of one style (a URL or style JSON, e.g. from
crate::providers): 800 x 600 CSS pixels at zoom 0.
Sourcepub fn stack(styles: Vec<String>) -> Self
pub fn stack(styles: Vec<String>) -> Self
A view of several styles drawn bottom to top (e.g. a basemap published as separate hillshade, base and label services).
Sourcepub fn center(self, longitude: f64, latitude: f64) -> Self
pub fn center(self, longitude: f64, latitude: f64) -> Self
View centre as (longitude, latitude).
Sourcepub fn bounds(self, bounds: [f64; 4], crs: Crs) -> Result<Self, BasemapError>
pub fn bounds(self, bounds: [f64; 4], crs: Crs) -> Result<Self, BasemapError>
Fit bounds ([xmin, ymin, xmax, ymax] in crs) instead of a
centre and zoom. Apply after size.
Sourcepub fn pixel_ratio(self, pixel_ratio: f64) -> Self
pub fn pixel_ratio(self, pixel_ratio: f64) -> Self
Device pixels per CSS pixel (MapLibre’s devicePixelRatio).
Sourcepub fn layers(self, layers: Vec<String>) -> Self
pub fn layers(self, layers: Vec<String>) -> Self
Layer filter applied to every style: plain IDs keep only those
layers, --prefixed IDs drop them.
Sourcepub fn labels(self, labels: Labels) -> Self
pub fn labels(self, labels: Labels) -> Self
Labels to keep in every style: all, none, or only the labels.
Sourcepub fn features(self, features: Vec<String>) -> Self
pub fn features(self, features: Vec<String>) -> Self
Feature filter applied to every style: plain names keep those
features ("water", "roads", …), --prefixed names drop them.
Sourcepub fn auth_token(self, token: impl Into<String>) -> Self
pub fn auth_token(self, token: impl Into<String>) -> Self
Access token for the tile service.
Sourcepub fn tile_timeout_ms(self, ms: u32) -> Self
pub fn tile_timeout_ms(self, ms: u32) -> Self
Per-tile HTTP timeout in milliseconds.
Sourcepub fn tile_concurrency(self, n: u32) -> Self
pub fn tile_concurrency(self, n: u32) -> Self
Parallel tile downloads.
Sourcepub fn fail_on_tile_error(self, fail: bool) -> Self
pub fn fail_on_tile_error(self, fail: bool) -> Self
Abort on a failed tile instead of leaving it empty.
Sourcepub fn set_view(
&mut self,
center: Option<(f64, f64)>,
zoom: Option<f64>,
) -> Result<&mut Self, BasemapError>
pub fn set_view( &mut self, center: Option<(f64, f64)>, zoom: Option<f64>, ) -> Result<&mut Self, BasemapError>
Set the centre and/or zoom (None keeps the current value).
Sourcepub fn set_bounds(
&mut self,
bounds: [f64; 4],
crs: Crs,
) -> Result<&mut Self, BasemapError>
pub fn set_bounds( &mut self, bounds: [f64; 4], crs: Crs, ) -> Result<&mut Self, BasemapError>
Fit the view to bounds in crs, keeping its size.
Sourcepub fn get_bounds(&self, lonlat: bool) -> [f64; 4]
pub fn get_bounds(&self, lonlat: bool) -> [f64; 4]
The view’s [xmin, ymin, xmax, ymax]: EPSG:3857 metres, or degrees
with lonlat.
Sourcepub fn get_center(&self) -> (f64, f64)
pub fn get_center(&self) -> (f64, f64)
The view centre as (longitude, latitude).
Sourcepub fn get_size(&self) -> (u32, u32)
pub fn get_size(&self) -> (u32, u32)
Size of rendered images in device pixels (width, height times
pixel_ratio).
Sourcepub fn get_attribution(&self) -> Result<String, BasemapError>
pub fn get_attribution(&self) -> Result<String, BasemapError>
The attribution text the view’s styles ask maps to show (see
crate::attribution()).
Sourcepub fn render_array(&self) -> Result<RenderResult, BasemapError>
pub fn render_array(&self) -> Result<RenderResult, BasemapError>
Render to straight-alpha RGBA pixels (device pixels).
Sourcepub fn render_png(&self, path: Option<&Path>) -> Result<Vec<u8>, BasemapError>
pub fn render_png(&self, path: Option<&Path>) -> Result<Vec<u8>, BasemapError>
Render a PNG, written to path when given; returns its bytes.
Sourcepub fn render_svg(
&self,
path: Option<&Path>,
options: &SvgOptions,
) -> Result<String, BasemapError>
pub fn render_svg( &self, path: Option<&Path>, options: &SvgOptions, ) -> Result<String, BasemapError>
Render a vector SVG (width x height user units; pixel_ratio
does not apply), written to path when given; returns the document.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Basemap
impl RefUnwindSafe for Basemap
impl Send for Basemap
impl Sync for Basemap
impl Unpin for Basemap
impl UnsafeUnpin for Basemap
impl UnwindSafe for Basemap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more