pub struct MapDisplay;Expand description
Deterministic label-layout policy.
Implementations§
Source§impl MapDisplay
impl MapDisplay
Sourcepub fn layout(
features: &[MapFeature],
viewport: Viewport,
zoom: u8,
requested_language: &str,
fallback_language: &str,
minimum_gap: f64,
) -> Result<Vec<PlacedLabel>, MapError>
pub fn layout( features: &[MapFeature], viewport: Viewport, zoom: u8, requested_language: &str, fallback_language: &str, minimum_gap: f64, ) -> Result<Vec<PlacedLabel>, MapError>
Places visible labels by priority while suppressing nearby collisions.
minimum_gap is Euclidean distance in normalized screen coordinates and
must be finite and non-negative.
Examples found in repository?
examples/layout_labels.rs (line 27)
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}Trait Implementations§
Source§impl Clone for MapDisplay
impl Clone for MapDisplay
impl Copy for MapDisplay
Source§impl Debug for MapDisplay
impl Debug for MapDisplay
Source§impl Default for MapDisplay
impl Default for MapDisplay
impl Eq for MapDisplay
Source§impl PartialEq for MapDisplay
impl PartialEq for MapDisplay
impl StructuralPartialEq for MapDisplay
Auto Trait Implementations§
impl Freeze for MapDisplay
impl RefUnwindSafe for MapDisplay
impl Send for MapDisplay
impl Sync for MapDisplay
impl Unpin for MapDisplay
impl UnsafeUnpin for MapDisplay
impl UnwindSafe for MapDisplay
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