pub struct MapView { /* private fields */ }
Expand description
Map view specifies the area of the map that should be drawn. In other words, it sets the position of “camera” that looks at the map.
The main view parameters are:
- position - coordinates of the point in the center of the map
- resolution - number of map units in a single pixel at the center of the map
- size - size of the rendering area in pixels
- crs - coordinate system that the map will be rendered to. This specifies the geographic projection that the map is displayed in. Note, that currently geographic CRSs are not supported, and a map with such a view will not be drawn.
The view can also specify rotation along x (tilt) and z (rotation) axis.
Implementations§
source§impl MapView
impl MapView
sourcepub fn new(position: &impl GeoPoint<Num = f64>, resolution: f64) -> Self
pub fn new(position: &impl GeoPoint<Num = f64>, resolution: f64) -> Self
Creates a new view with the given position and resolution with default CRS (web-mercator EPSG:3857).
sourcepub fn new_with_crs(
position: &impl GeoPoint<Num = f64>,
resolution: f64,
crs: Crs
) -> Self
pub fn new_with_crs( position: &impl GeoPoint<Num = f64>, resolution: f64, crs: Crs ) -> Self
Creates a new view with the given CRS.
sourcepub fn new_projected(
position: &impl CartesianPoint2d<Num = f64>,
resolution: f64
) -> Self
pub fn new_projected( position: &impl CartesianPoint2d<Num = f64>, resolution: f64 ) -> Self
Creates a new view, taking position value as projected coordinates. Default CRS is used (EPSG:3857).
sourcepub fn new_projected_with_crs(
position: &impl CartesianPoint2d<Num = f64>,
resolution: f64,
crs: Crs
) -> Self
pub fn new_projected_with_crs( position: &impl CartesianPoint2d<Num = f64>, resolution: f64, crs: Crs ) -> Self
Creates a new view, taking position value as projected coordinates.
sourcepub fn position(&self) -> Option<GeoPoint2d>
pub fn position(&self) -> Option<GeoPoint2d>
Position of the center point of the map (screen).
If the projected position cannot be projected into geographic coordinates, None
is returned.
sourcepub fn resolution(&self) -> f64
pub fn resolution(&self) -> f64
Resolution at the center of the map.
sourcepub fn with_resolution(&self, resolution: f64) -> Self
pub fn with_resolution(&self, resolution: f64) -> Self
Creates a new view, same as the current one, but with the given resolution.
sourcepub fn with_size(&self, new_size: Size) -> Self
pub fn with_size(&self, new_size: Size) -> Self
Creates a new view, same as the current one, but with the given size.
sourcepub fn get_bbox(&self) -> Option<Rect>
pub fn get_bbox(&self) -> Option<Rect>
Returns bounding rectangle of the view (in projected coordinates).
sourcepub fn map_to_scene_transform(&self) -> Option<OMatrix<f64, U4, U4>>
pub fn map_to_scene_transform(&self) -> Option<OMatrix<f64, U4, U4>>
Returns transformation matrix that transforms map coordinates to scene coordinates.
Scene coordinates are [-1.0, 1.0]
coordinates of the render area with Y going from bottom to top.
sourcepub fn map_to_scene_mtx(&self) -> Option<[[f32; 4]; 4]>
pub fn map_to_scene_mtx(&self) -> Option<[[f32; 4]; 4]>
Returns transformation matrix that transforms map coordinates to scene coordinates.
Scene coordinates are [-1.0, 1.0]
coordinates of the render area with Y going from bottom to top.
sourcepub fn rotation_x(&self) -> f64
pub fn rotation_x(&self) -> f64
Rotation angle around X axis in radians (tilt).
sourcepub fn rotation_z(&self) -> f64
pub fn rotation_z(&self) -> f64
Rotation angle around Z axis in radians.
sourcepub fn with_rotation_x(&self, rotation_x: f64) -> Self
pub fn with_rotation_x(&self, rotation_x: f64) -> Self
Creates a new view, same as the current one, but with the given rotation x.
sourcepub fn with_rotation_z(&self, rotation_z: f64) -> Self
pub fn with_rotation_z(&self, rotation_z: f64) -> Self
Creates a new view, same as the current one, but with the given rotation z.
sourcepub fn with_rotation(&self, rotation_x: f64, rotation_z: f64) -> Self
pub fn with_rotation(&self, rotation_x: f64, rotation_z: f64) -> Self
Creates a new view, same as the current one, but with the given rotation values.
sourcepub fn screen_to_map(&self, px_position: Point2d) -> Option<Point2d>
pub fn screen_to_map(&self, px_position: Point2d) -> Option<Point2d>
Projects the given screen point into map coordinates at the 0 elevation.
Returns None
if the point is outside of map (this can be possible, if the map is tilted and the point is
above the horizon, or if the point is outside the projection bounds).
sourcepub fn screen_to_map_geo(&self, px_position: Point2d) -> Option<GeoPoint2d>
pub fn screen_to_map_geo(&self, px_position: Point2d) -> Option<GeoPoint2d>
Projects the given screen point into map coordinates at the 0 elevation, and then projects them into geographic coordinates.
Returns None
if the point is outside of map (this can be possible, if the map is tilted and the point is
above the horizon, or if the point is outside the projection bounds).
sourcepub fn translate_by_pixels(&self, from: Point2d, to: Point2d) -> Self
pub fn translate_by_pixels(&self, from: Point2d, to: Point2d) -> Self
Creates a new view, same as the current one, but translated so that point from
on the current view becomes
the point to
in the new view.
Trait Implementations§
Auto Trait Implementations§
impl Send for MapView
impl Sync for MapView
impl RefUnwindSafe for MapView
impl Unpin for MapView
impl UnwindSafe for MapView
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.