# MapViewport

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-livecharts/geo_map_chart_engine/struct-mapviewport/

**struct** · [`ferroui-livecharts`](/docs/0.5.0/api/ferroui-livecharts/) · v0.5.0

```rust
struct MapViewport
```

The pan and zoom of a map (`MapViewportTransform`, `GeoMapChart.ZoomLevel` and `PanOffset`):
a projected position `p` is drawn at `p * zoom + center * (1 - zoom) + pan`, where `center`
is the centre of the control. The stroke of the lands scales with the zoom, as the source's
canvas matrix scales it.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L152)

## Members

- [`zoom`](#struct_field-zoom)
- [`pan`](#struct_field-pan)
- [`new`](#function-new)
- [`is_identity`](#function-is_identity)
- [`transform`](#function-transform)
- [`inverse`](#function-inverse)
- [`panned`](#function-panned)
- [`zoomed`](#function-zoomed)
- [`bounce_back_target`](#function-bounce_back_target)
- [`interpolate`](#function-interpolate)

<a id="struct_field-zoom"></a>

### zoom

```rust
zoom: f64
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L153)

<a id="struct_field-pan"></a>

### pan

```rust
pan: ferroui_base::Point
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L154)

<a id="function-new"></a>

### new

```rust
fn new(zoom: f64, pan: Point) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L165)

<a id="function-is_identity"></a>

### is_identity

```rust
fn is_identity(self: &Self) -> bool
```

Whether the viewport changes nothing (the opposite of `IsActive`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L170)

<a id="function-transform"></a>

### transform

```rust
fn transform(self: &Self, point: Point, center: Point) -> Point
```

The screen position of a projected position.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L178)

<a id="function-inverse"></a>

### inverse

```rust
fn inverse(self: &Self, point: Point, center: Point) -> Point
```

The projected position of a screen position (`InverseViewportTransform`); a zoom of 0 is
taken as 1.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L187)

<a id="function-panned"></a>

### panned

```rust
fn panned(self: &Self, delta: Point) -> Self
```

The viewport moved by a screen distance (`MapFactory.Pan`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L196)

<a id="function-zoomed"></a>

### zoomed

```rust
fn zoomed(self: &Self, pivot: Point, direction: ZoomDirection, speed: f64, min_zoom: f64, max_zoom: f64, center: Point) -> Self
```

One zoom step about a screen position, which stays in place (`MapFactory.Zoom`). The
speed is clamped to [0.1, 0.95]; a step in multiplies the zoom by `1 / (1 - speed)`, a step
out by `1 - speed`. The zoom stays at most `max_zoom` and at least `0.8 * min_zoom`, the
overshoot that the bounce back of a release takes back.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L207)

<a id="function-bounce_back_target"></a>

### bounce_back_target

```rust
fn bounce_back_target(self: &Self, control: Size, min_zoom: f64) -> Option<Self>
```

Where a release settles the viewport (`BounceBack`): the zoom back to at least
`min_zoom` and the map, the size of the control at that zoom, panned to cover the control.
`None` when the viewport is already there.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L244)

<a id="function-interpolate"></a>

### interpolate

```rust
fn interpolate(self: &Self, to: &Self, t: f64) -> Self
```

The viewport `t` of the way from this one to `to`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/geo_map_chart_engine.rs#L288)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Copy`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Default`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
