Skip to main content

Map

Struct Map 

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

See map.

Implementations§

Source§

impl Map

Source

pub fn start(self, center: Point, scale: f32) -> Self

Opens centred on center (from MapBuilder::point) at scale logical px per metre, instead of fitting the whole map.

Source

pub fn focus(self, focus: Option<(Point, f32)>) -> Self

Centres on center and zooms in to at least scale whenever this differs from the focus of the last build, e.g. to show a search result.

Source

pub fn fit(self, bounds: Rect) -> Self

Fits bounds (in MapBuilder::point units) to the widget, zooming in or out, whenever they differ from the last build’s, e.g. to show one region and then the whole map again.

Source

pub fn overlay( self, f: impl Fn(&mut PaintCx<'_>, &dyn Fn(Point) -> Point) + 'static, ) -> Self

Paints over the map, given a function from map points to logical px, e.g. to draw markers that keep their size while zooming.

Source

pub fn on_tap(self, f: impl Fn(&mut EventCx<'_>, Point) + 'static) -> Self

Runs on a tap that didn’t pan or pinch, with the map point under it in MapBuilder::point metres.

Source

pub fn on_tap_scaled( self, f: impl Fn(&mut EventCx<'_>, Point, f32) + 'static, ) -> Self

Map::on_tap, also given the scale in logical px per metre, e.g. to take taps within a few px of a marker.

Trait Implementations§

Source§

impl From<Map> for Element

Source§

fn from(w: Map) -> Self

Converts to this type from the input type.
Source§

impl Styled for Map

Source§

fn style_mut(&mut self) -> &mut Style

The taffy style the modifiers write; also an escape hatch for the rest.
Source§

fn padding(self, p: f32) -> Self

Space between the box’s edges and its children on all sides, logical px.
Source§

fn padding_xy(self, x: f32, y: f32) -> Self

Padding of x left and right and y top and bottom, logical px.
Source§

fn padding_top(self, p: f32) -> Self

Padding on the top only, logical px, over what padding or padding_xy set before it, e.g. clearing the status bar.
Source§

fn padding_right(self, p: f32) -> Self

Padding on the right only, logical px; see padding_top.
Source§

fn padding_bottom(self, p: f32) -> Self

Padding on the bottom only, logical px; see padding_top.
Source§

fn padding_left(self, p: f32) -> Self

Padding on the left only, logical px; see padding_top.
Source§

fn gap(self, g: f32) -> Self

Space between children, along both axes, logical px.
Source§

fn grow(self, g: f32) -> Self

Share of the parent’s spare main-axis space to take; 0 by default. The content still sets the minimum, so see fill around a scroll(). With a zero size on that axis, siblings split the space by their shares alone: height(0.0).grow(1.0) over height(0.0).grow(2.0) is a third and two thirds.
Source§

fn shrink(self, s: f32) -> Self

How much to give up when the parent is too small; 1 by default, 0 keeps the size, e.g. a short label beside a long one in a row.
Source§

fn width(self, w: f32) -> Self

Fixed width, logical px.
Source§

fn height(self, h: f32) -> Self

Fixed height, logical px.
Source§

fn min_width(self, w: f32) -> Self

Lower bound on the width, logical px; min_width(0.0) lets a flex child shrink below its content.
Source§

fn min_height(self, h: f32) -> Self

Lower bound on the height, logical px; min_height(0.0) lets a flex child shrink below its content.
Source§

fn max_height(self, h: f32) -> Self

Upper bound on the height, logical px, e.g. a scroll() that grows with its content up to a point.
Source§

fn fill(self) -> Self

Takes the space left along the parent’s main axis, and no more: unlike grow(1.0), the content’s size doesn’t push the parent. Use it on every flex box between the window and a scroll(). In a row, siblings that all fill get equal widths, whatever their content.
Source§

fn fill_width(self) -> Self

As wide as the parent’s content box, whatever the flex direction.
Source§

fn align(self, a: AlignItems) -> Self

Places children on the cross axis: across a row, along a column.
Source§

fn justify(self, j: AlignContent) -> Self

Distributes children and spare space along the main axis.
Source§

fn wrap(self) -> Self

Children that don’t fit start a new line instead of shrinking.
Source§

impl Widget for Map

Source§

fn style(&self) -> Style

Source§

fn paint(&self, cx: &mut PaintCx<'_>)

Source§

fn event(&self, ev: &Event, cx: &mut EventCx<'_>)

Pointer events reach a widget while the pointer is over it, once more when it leaves, and throughout a press that began on it; layers get them all.
Source§

fn children(&self) -> &[Element]

Source§

fn expand(&self, _cx: &mut BuildCx<'_>)

Runs before children with this node’s id, state slot and providers; lets a widget build its subtree from framework-owned state.
Source§

fn layer(&self) -> Option<Layer>

Takes this subtree out of the layout flow: it covers Layer’s box, isn’t clipped by ancestors, paints above and gets input before the rest of the tree.
Source§

fn inert(&self) -> bool

Whether this subtree is drawn but ignores the pointer.
Source§

fn focus(&self) -> Option<Focus>

Lets Tab move keyboard focus here. The focused widget gets keys first and handles Enter, Space or arrows when EventCx::focused.
Source§

fn provide(&self) -> Option<&(dyn Any + 'static)>

Value made available to descendants through Scope::get.
Source§

fn measure( &self, _known: Size<Option<f32>>, _available: Size<AvailableSpace>, _text: &Text, ) -> Size<f32>

Intrinsic size of a leaf (children-less) widget.
Source§

fn measure_key(&self) -> u64

Hash of everything measure reads besides its arguments. Layout is kept across rebuilds and a leaf is only re-measured when this changes, so widgets whose size depends on their data must override it.
Source§

fn scroll( &self, _state: &mut State, _at: Placement, _now: Instant, ) -> Option<(f32, f32)>

Children are clipped to at.clip and shifted by the returned offset, as of frame time now.
Source§

fn clips(&self) -> bool

Whether children moved by scroll are clipped to this widget’s box.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Map

§

impl !Send for Map

§

impl !Sync for Map

§

impl !UnwindSafe for Map

§

impl Forget for Map

§

impl Freeze for Map

§

impl Move for Map

§

impl Unpin for Map

§

impl UnsafeUnpin for Map

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more