Skip to main content

View

Struct View 

Source
pub struct View {
    pub center: LonLat,
    pub zoom: f64,
    pub bearing: f64,
    pub pitch: f64,
}
Expand description

Map camera state.

Fields§

§center: LonLat§zoom: f64

Zoom level, fractional allowed.

§bearing: f64

Bearing in degrees clockwise from north.

§pitch: f64

Pitch (tilt) in degrees, 0 = top-down.

Implementations§

Source§

impl View

Source

pub fn new(center: LonLat, zoom: f64) -> Self

Source

pub fn set_pitch(&mut self, pitch: f64)

Set pitch in degrees, clamped to [0, 60] like the TS engine.

Source

pub fn set_bearing(&mut self, bearing: f64)

Set bearing, normalized to [0, 360).

Source

pub fn scale(&self) -> f64

Pixel scale factor: world pixels per screen pixel at this zoom.

Source

pub fn project(&self, p: LonLat, viewport_w: f64, viewport_h: f64) -> (f64, f64)

Convert a lon/lat to screen pixels relative to the view center, given the viewport size. Bearing rotation is applied.

Source

pub fn unproject( &self, sx: f64, sy: f64, viewport_w: f64, viewport_h: f64, ) -> LonLat

Inverse of View::project (ignores pitch foreshortening).

Source

pub fn visible_tiles( &self, viewport_w: f64, viewport_h: f64, ) -> (u32, u32, u32, u32)

Visible tile range for a viewport: (x0, y0, x1, y1) inclusive at floored zoom.

Trait Implementations§

Source§

impl Clone for View

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 View

Source§

impl Debug for View

Source§

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

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

impl Default for View

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for View

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for View

Auto Trait Implementations§

§

impl Freeze for View

§

impl RefUnwindSafe for View

§

impl Send for View

§

impl Sync for View

§

impl Unpin for View

§

impl UnsafeUnpin for View

§

impl UnwindSafe for View

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.