Skip to main content

MapView

Struct MapView 

Source
pub struct MapView {
    pub center: Signal<LngLat>,
    pub zoom: Signal<f64>,
    pub bearing: Signal<f64>,
    pub status: Signal<MapStatus>,
    pub attribution: Signal<String>,
    pub markers: Signal<Vec<(MarkerId, Marker)>>,
    pub tap: Signal<Option<MapTap>>,
    pub overlays: Signal<Vec<Overlay>>,
    pub interaction: Signal<Interaction>,
    pub request: Signal<Option<CameraRequest>>,
    /* private fields */
}
Expand description

The state of a map, shared between the piece and the app: where it looks and how close, which the app sets to move the map and reads to learn where the user took it, plus what the piece reports back about loading and drawing.

Fields§

§center: Signal<LngLat>

Center in WGS84 degrees; longitude comes first.

§zoom: Signal<f64>

Web Mercator zoom with a 512-point world at zoom zero. Providers clamp to their limits.

§bearing: Signal<f64>

Clockwise heading in degrees; zero is north.

§status: Signal<MapStatus>

Provider loading state. Failure details are diagnostic, not localized UI text.

§attribution: Signal<String>

Provider credits, when supplied as text. Native SDKs retain their attribution controls.

§markers: Signal<Vec<(MarkerId, Marker)>>

Ordered annotations. Prefer the marker methods to preserve stable identities.

§tap: Signal<Option<MapTap>>

Last map or marker tap. Native SDKs may reserve double taps for zooming.

§overlays: Signal<Vec<Overlay>>

Geometry drawn above the basemap and below annotations, in list order.

§interaction: Signal<Interaction>

Which user camera gestures are enabled; programmatic moves remain available.

§request: Signal<Option<CameraRequest>>

Provider-facing command stream. Observe serial numbers; do not replay on remount.

Implementations§

Source§

impl MapView

Source

pub fn new(center: LngLat, zoom: f64) -> MapView

Source

pub fn add_marker(&self, marker: Marker) -> MarkerId

Put a marker on the map.

Source

pub fn update_marker(&self, id: MarkerId, marker: Marker) -> bool

Replace a marker in place, keeping its id: a new title or position. false when id is no longer on the map.

Source

pub fn remove_marker(&self, id: MarkerId)

Take a marker off the map.

Source

pub fn clear_markers(&self)

Source

pub fn marker(&self, id: MarkerId) -> Option<Marker>

The marker with id, if it is still on the map.

Source

pub fn fly_to(&self, center: LngLat, zoom: f64)

Animate to center at zoom. The canvas renderer uses a one-second flight; native SDKs choose their own trajectory and may approximate the requested duration.

Source

pub fn fly_to_with( &self, center: LngLat, zoom: f64, bearing: Option<f64>, duration: f64, )

MapView::fly_to with the bearing to arrive at (None keeps the current one) and the requested duration in seconds; 0.0 jumps. MapKit uses its standard animation timing for positive durations.

Source

pub fn fit_bounds(&self, sw: LngLat, ne: LngLat, padding: f64)

Glide to the north-up view that shows the box from sw to ne whole, with padding points kept clear on every side.

Source

pub fn rotate_to(&self, bearing: f64)

Turn to bearing degrees (clockwise, 0.0 north up) over half a second, the position at the center held.

Source

pub fn reset_north(&self)

Turn back to north up.

Source

pub fn zoom_by(&self, levels: f64)

Zoom by levels (negative zooms out), keeping the center.

Source

pub fn jump_to(&self, center: LngLat, zoom: f64)

Look at center from zoom, at once.

Source

pub fn jump_to_with(&self, center: LngLat, zoom: f64, bearing: f64)

MapView::jump_to with the bearing too (0.0 is north up).

Trait Implementations§

Source§

impl Clone for MapView

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for MapView

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.