Viewport

class Viewport(**properties: Any)

Superclasses: Object

Implemented Interfaces: Location

The object holding the coordinate, zoom-level, and rotation state of the current view.

As the object implements Location, the latitude and longitude are accessible via the interface methods.

Constructors

class Viewport
classmethod new() Viewport

Creates a new Viewport

Methods

class Viewport
get_max_zoom_level() int

Get the maximal zoom level

get_min_zoom_level() int

Get the minimal zoom level

get_reference_map_source() MapSource | None

Get the reference map source

get_rotation() float

Gets the current rotation

get_zoom_level() float

Get the current zoom level

location_to_widget_coords(widget: Widget, latitude: float, longitude: float) tuple[float, float]

Gets the position on widget that correspond to the given latitude and longitude.

Parameters:
  • widget – a Widget that uses self as viewport

  • latitude – the latitude

  • longitude – the longitude

set_max_zoom_level(max_zoom_level: int) None

Set the maximal zoom level

Parameters:

max_zoom_level – the maximal zoom level

set_min_zoom_level(min_zoom_level: int) None

Set the minimal zoom level

Parameters:

min_zoom_level – the minimal zoom level

set_reference_map_source(map_source: MapSource | None = None) None

Set the reference map source

Parameters:

map_source – a MapSource or None to set none.

set_rotation(rotation: float) None

Sets the rotation

Parameters:

rotation – the rotation

set_zoom_level(zoom_level: float) None

Set the zoom level

Parameters:

zoom_level – the zoom level

widget_coords_to_location(widget: Widget, x: float, y: float) tuple[float, float]

Gets the latitude and longitude corresponding to a position on widget.

Parameters:
  • widget – a Widget that uses self as viewport

  • x – the x coordinate

  • y – the y coordinate

Properties

class Viewport
props.max_zoom_level: int

The highest allowed level of zoom of the content.

props.min_zoom_level: int

The lowest allowed level of zoom of the content.

props.reference_map_source: MapSource

The reference MapSource being displayed

props.rotation: float

The rotation of the map view, in radians clockwise from up being due north

props.zoom_level: float

The level of zoom of the content.