Skip to main content

MapProjectionHandle

Struct MapProjectionHandle 

Source
pub struct MapProjectionHandle { /* private fields */ }
Expand description

Owns one native handle.

A camera view for converting between screen points and coordinates.

See mln_map_projection in the C API reference.

Implementations§

Source§

impl MapProjectionHandle

Source

pub fn id(&self) -> u64

Returns the native handle value.

Source§

impl MapProjectionHandle

Source

pub fn create(view: &MapView) -> Result<MapProjectionHandle>

Creates a projection that converts coordinates for one view of a map.

Create it from the view of an MapSnapshot or an RenderFrameResult. The projection doesn’t follow the map, so create a new one after the map’s camera or size changes.

See mln_map_projection_create in the C API reference.

Source

pub fn get_camera(&self) -> Result<MapProjectionCameraResult>

Reads the projection’s camera.

See mln_map_projection_get_camera in the C API reference.

Source

pub fn lat_lng_for_pixel(&self, point: ScreenPoint) -> Result<LatLng>

Finds the coordinate at a screen point.

The longitude stays between -180 and 180.

See mln_map_projection_lat_lng_for_pixel in the C API reference.

Source

pub fn lat_lng_for_pixel_unwrapped(&self, point: ScreenPoint) -> Result<LatLng>

Finds the coordinate at a screen point, without wrapping its longitude.

The longitude can fall outside -180 to 180, to show which copy of the world the point is in.

See mln_map_projection_lat_lng_for_pixel_unwrapped in the C API reference.

Source

pub fn lat_lngs_for_pixels(&self, points: &[ScreenPoint]) -> Result<Vec<LatLng>>

Finds the coordinates at several screen points, as MapProjectionHandle::lat_lng_for_pixel() does.

See mln_map_projection_lat_lngs_for_pixels in the C API reference.

Source

pub fn lat_lngs_for_pixels_unwrapped( &self, points: &[ScreenPoint], ) -> Result<Vec<LatLng>>

Finds the coordinates at several screen points, as MapProjectionHandle::lat_lng_for_pixel_unwrapped() does.

See mln_map_projection_lat_lngs_for_pixels_unwrapped in the C API reference.

Source

pub fn meters_per_pixel_at_latitude(&self, latitude: f64) -> Result<f64>

Computes how many meters one screen pixel covers at latitude, at the projection’s zoom.

The result ignores the camera’s pitch.

See mln_map_projection_meters_per_pixel_at_latitude in the C API reference.

Source

pub fn pixel_for_lat_lng(&self, coordinate: LatLng) -> Result<ScreenPoint>

Finds the screen point of a coordinate.

The point is in the copy of the world nearest the camera’s center.

See mln_map_projection_pixel_for_lat_lng in the C API reference.

Source

pub fn pixels_for_lat_lngs( &self, coordinates: &[LatLng], ) -> Result<Vec<ScreenPoint>>

Finds the screen points of several coordinates, as MapProjectionHandle::pixel_for_lat_lng() does.

See mln_map_projection_pixels_for_lat_lngs in the C API reference.

Source

pub fn release(self) -> Result<(), ReleaseError<Self>>

Releases a projection.

See mln_map_projection_release in the C API reference.

Source

pub fn set_camera(&self, camera: &CameraOptions) -> Result<()>

Moves the projection’s camera, without changing the map.

Camera fields that camera doesn’t set keep their values.

See mln_map_projection_set_camera in the C API reference.

Trait Implementations§

Source§

impl Debug for MapProjectionHandle

Source§

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

Formats the value using the given formatter. Read more

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
§

impl<T> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.