Map

class Map(**properties: Any)

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget

The Map widget is a Widget that show and allows interaction with the user.

This is the base widget and doesn’t have advanced features. You can check the SimpleMap for a ready-to-use widget.

By default, a Viewport is created and can be accessed with get_viewport.

Unless created with new_simple, the widget doesn’t hold any layer and won’t show anything. A Layer can be added or removed using the add_layer or remove_layer methods.

Constructors

class Map
classmethod new() Map

Creates an instance of Map.

classmethod new_simple() Map

Methods

class Map
add_layer(layer: Layer) None

Adds a new layer to the view

Parameters:

layer – a Layer

center_on(latitude: float, longitude: float) None

Centers the map on these coordinates.

Parameters:
  • latitude – the longitude to center the map at

  • longitude – the longitude to center the map at

get_animate_zoom() bool

Checks whether the view animates zoom level changes.

get_go_to_duration() int

Get the ‘go-to-duration’ property.

get_state() State

Gets the view’s state.

get_viewport() Viewport

Get the Viewport used by this view.

get_zoom_on_double_click() bool

Checks whether the view zooms on double click.

go_to(latitude: float, longitude: float) None

Move from the current position to these coordinates. All tiles in the intermediate view WILL be loaded!

Parameters:
  • latitude – the longitude to center the map at

  • longitude – the longitude to center the map at

go_to_full(latitude: float, longitude: float, zoom_level: float) None

Move from the current position to these coordinates and zoom to the given zoom level. All tiles in the intermediate view WILL be loaded!

Parameters:
  • latitude – the longitude to center the map at

  • longitude – the longitude to center the map at

  • zoom_level – the zoom level to end at

go_to_full_with_duration(latitude: float, longitude: float, zoom_level: float, duration_ms: int) None

Move from the current position to these coordinates and zoom to the given zoom level. The given duration is used instead of the map’s default go_to_duration. All tiles in the intermediate view WILL be loaded!

Parameters:
  • latitude – the longitude to center the map at

  • longitude – the longitude to center the map at

  • zoom_level – the zoom level to end at

  • duration_ms – animation duration in milliseconds

insert_layer_above(layer: Layer, next_sibling: Layer | None = None) None

Adds layer to self above next_sibling or, if next_sibling is None, at the bottom of the layer list.

Parameters:
  • layer – a Layer

  • next_sibling – a Layer that is a child of self, or None

insert_layer_behind(layer: Layer, next_sibling: Layer | None = None) None

Adds layer to self behind next_sibling or, if next_sibling is None, at the top of the layer list.

Parameters:
  • layer – a Layer

  • next_sibling – a Layer that is a child of self, or None

remove_layer(layer: Layer) None

Removes the given layer from the view

Parameters:

layer – a Layer

set_animate_zoom(value: bool) None

Should the view animate zoom level changes.

Parameters:

value – a gboolean

set_go_to_duration(duration: int) None

Set the duration of the transition of go_to.

Parameters:

duration – the animation duration, in milliseconds

set_map_source(map_source: MapSource) None

Changes the currently used map source. ``g_object_unref``() will be called on the previous one.

As a side effect, changing the primary map source will also clear all secondary map sources.

Parameters:

map_source – a MapSource

set_zoom_on_double_click(value: bool) None

Should the view zoom in and recenter when the user double click on the map.

Parameters:

value – a gboolean

stop_go_to() None

Stop the go to animation. The view will stay where it was when the animation was stopped.

zoom_in() None

Zooms the map in. If animate_zoom is TRUE, the change will be animated.

zoom_out() None

Zooms the map out. If animate_zoom is TRUE, the change will be animated.

Properties

class Map
props.animate_zoom: bool

Animate zoom change when zooming in/out.

props.go_to_duration: int

The duration of an animation when going to a location, in milliseconds. A value of 0 means that the duration is calculated automatically for you.

Please note that animation of shumate_map_ensure_visible also involves a ‘go-to’ animation.

props.state: State

The view’s global state. Useful to inform using if the view is busy loading tiles or not.

props.viewport: Viewport

The viewport, which contains information about the center, rotation, zoom, etc. of the map.

props.zoom_on_double_click: bool

Should the view zoom in and recenter when the user double click on the map.

Signals

class Map.signals
animation_completed() None

The Map::animation-completed signal is emitted when any animation in the view ends. This is a detailed signal. For example, if you want to be signaled only for go-to animation, you should connect to “animation-completed::go-to”. And for zoom, connect to “animation-completed::zoom”.