pub struct Viewport { /* private fields */ }Expand description
Geographic area displayed by a map, including antimeridian-wrapping areas.
Implementations§
Source§impl Viewport
impl Viewport
Sourcepub fn new(
south: f64,
west: f64,
north: f64,
east: f64,
) -> Result<Self, MapError>
pub fn new( south: f64, west: f64, north: f64, east: f64, ) -> Result<Self, MapError>
Creates a viewport. west > east represents wrapping across ±180°.
Examples found in repository?
examples/layout_labels.rs (line 22)
21fn main() -> Result<(), Box<dyn std::error::Error>> {
22 let viewport = Viewport::new(35.5, 139.4, 35.9, 140.0)?;
23 let features = vec![
24 feature("駅", 35.6812, 139.7671, LabelPriority::Transit)?,
25 feature("広場", 35.6820, 139.7680, LabelPriority::Local)?,
26 ];
27 let labels = MapDisplay::layout(&features, viewport, 12, "ja", "ja", 0.02)?;
28 for label in labels {
29 println!(
30 "{} at ({:.3}, {:.3})",
31 label.text,
32 label.position.x(),
33 label.position.y()
34 );
35 }
36 Ok(())
37}Sourcepub fn contains(self, point: GeoPoint) -> bool
pub fn contains(self, point: GeoPoint) -> bool
Returns true when the point is inside this viewport.
Sourcepub fn project(self, point: GeoPoint) -> Option<ScreenPoint>
pub fn project(self, point: GeoPoint) -> Option<ScreenPoint>
Projects a contained point to normalized screen coordinates.
Trait Implementations§
impl Copy for Viewport
impl StructuralPartialEq for Viewport
Auto Trait Implementations§
impl Freeze for Viewport
impl RefUnwindSafe for Viewport
impl Send for Viewport
impl Sync for Viewport
impl Unpin for Viewport
impl UnsafeUnpin for Viewport
impl UnwindSafe for Viewport
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
Mutably borrows from an owned value. Read more