OsmGpsMap.Map

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Buildable->Gtk.Widget Gtk.DrawingArea Gtk.DrawingArea OsmGpsMap.Map OsmGpsMap.Map Gtk.DrawingArea->OsmGpsMap.Map Gtk.Widget->Gtk.DrawingArea

Subclasses:

None

Methods

Inherited:

Gtk.DrawingArea (1), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)

Structs:

Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

get_default_cache_directory ()

class

new ()

class

source_get_copyright (source)

class

source_get_friendly_name (source)

class

source_get_image_format (source)

class

source_get_max_zoom (source)

class

source_get_min_zoom (source)

class

source_get_repo_uri (source)

class

source_is_valid (source)

convert_geographic_to_screen (pt)

convert_screen_to_geographic (pixel_x, pixel_y)

download_cancel_all ()

download_maps (pt1, pt2, zoom_start, zoom_end)

get_bbox ()

get_event_location (event)

get_scale ()

gps_add (latitude, longitude, heading)

gps_clear ()

gps_get_track ()

image_add (latitude, longitude, image)

image_add_with_alignment (latitude, longitude, image, xalign, yalign)

image_add_with_alignment_z (latitude, longitude, image, xalign, yalign, zorder)

image_add_z (latitude, longitude, image, zorder)

image_remove (image)

image_remove_all ()

layer_add (layer)

layer_remove (layer)

layer_remove_all ()

map_redraw ()

map_redraw_idle ()

polygon_add (poly)

polygon_remove (poly)

polygon_remove_all ()

scroll (dx, dy)

set_center (latitude, longitude)

set_center_and_zoom (latitude, longitude, zoom)

set_keyboard_shortcut (key, keyval)

set_zoom (zoom)

set_zoom_offset (zoom_offset)

track_add (track)

track_remove (track)

track_remove_all ()

zoom_fit_bbox (latitude1, latitude2, longitude1, longitude2)

zoom_in ()

zoom_out ()

Virtual Methods

Inherited:

Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)

do_draw_gps_point (cr)

Properties

Inherited:

Gtk.Widget (39)

Name

Type

Flags

Short Description

auto-center

bool

r/w/c

map auto center

auto-center-threshold

float

r/w/c

the amount of the window the gps point must move before auto centering

auto-download

bool

r/w/c

map auto download

drag-limit

int

r/w/co

The number of pixels the user has to move the pointer in order to start dragging

gps-track-highlight-radius

int

r/w/c

The radius of the gps point highlight circle

gps-track-point-radius

int

r/w/c

The radius of the gps point inner circle

gps-track-width

float

r/w/c

The width of the lines drawn for the gps track

image-format

str

r/w/co

The map source tile repository image format (jpg, png)

latitude

float

r

Latitude in degrees

longitude

float

r

Longitude in degrees

map-source

int

r/w/c

The map source ID

map-x

int

r/w/co

Initial map x location

map-y

int

r/w/co

Initial map y location

max-zoom

int

r/w/co

Maximum zoom level

min-zoom

int

r/w/co

Minimum zoom level

proxy-uri

str

r/w/co

HTTP proxy uri or None

record-trip-history

bool

r/w/c

should all gps points be recorded in a trip history

repo-uri

str

r/w/co

Map source tile repository uri

show-gps-point

bool

r/w/c

should the current gps point be shown on the map

show-trip-history

bool

r/w/c

should the recorded trip history be shown on the map

tile-cache

str

r/w/c

Tile cache dir

tile-cache-base

str

r/w/co

Base directory to which friendly and auto paths are appended

tile-zoom-offset

int

r/w/co

Number of zoom-levels to upsample tiles

tiles-queued

int

r

The number of tiles currently waiting to download

user-agent

str

r/w/c

HTTP user agent or None

zoom

int

r/w/co

Map zoom level

Style Properties

Inherited:

Gtk.Widget (17)

Signals

Inherited:

Gtk.Widget (69), GObject.Object (1)

Name

Short Description

changed

The OsmGpsMap.Map ::changed signal is emitted any time the map zoom or map center is chaged (such as by dragging or zooming).

Fields

Inherited:

Gtk.Widget (69), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gtk.DrawingArea

r

Class Details

class OsmGpsMap.Map(**kwargs)
Bases:

Gtk.DrawingArea

Abstract:

No

Structure:

OsmGpsMap.MapClass

classmethod get_default_cache_directory()
Return type:

str

Returns (transfer full): the default cache directory for the library, that is the base directory to which the full cache path is appended. If OsmGpsMap.Map :tile-cache-base is omitted from the constructor then this value is used.

classmethod new()
Returns:

a newly created OsmGpsMap.Map object.

Return type:

Gtk.Widget

Returns a new OsmGpsMap.Map object, defaults to showing data from

OpenStreetMap See the properties description for more information about construction parameters than could be passed to g_object_new()

Parameters:

source (OsmGpsMap.MapSource_t) – a OsmGpsMap.MapSource_t source id

Returns:

Source copyright information

Return type:

str

Get copyright information for the source

New in version 1.2.0.

classmethod source_get_friendly_name(source)
Parameters:

source (OsmGpsMap.MapSource_t) – a OsmGpsMap.MapSource_t source id

Returns:

Nice printable source name

Return type:

str

Get friendly name for source

New in version 0.7.0.

classmethod source_get_image_format(source)
Parameters:

source (OsmGpsMap.MapSource_t) – a OsmGpsMap.MapSource_t source id

Returns:

source tile image format

Return type:

str

Get tile image format for the source

New in version 0.7.0.

classmethod source_get_max_zoom(source)
Parameters:

source (OsmGpsMap.MapSource_t) – a OsmGpsMap.MapSource_t source id

Returns:

source maximum zoom level

Return type:

int

Get maximum zoom level for the source

New in version 0.7.0.

classmethod source_get_min_zoom(source)
Parameters:

source (OsmGpsMap.MapSource_t) – a OsmGpsMap.MapSource_t source id

Returns:

source minimum zoom level

Return type:

int

Get minimum zoom level for the source

New in version 0.7.0.

classmethod source_get_repo_uri(source)
Parameters:

source (OsmGpsMap.MapSource_t) – a OsmGpsMap.MapSource_t source id

Returns:

Source repo URI

Return type:

str

Get repository URI address for the source

New in version 0.7.0.

classmethod source_is_valid(source)
Parameters:

source (OsmGpsMap.MapSource_t) – a OsmGpsMap.MapSource_t source id

Returns:

Validity of the source (whether repo uri is not null)

Return type:

bool

Check whether source is considered valid

New in version 0.7.0.

convert_geographic_to_screen(pt)
Parameters:

pt (OsmGpsMap.MapPoint) – location

Returns:

pixel_x:

pixel location on map, x axis

pixel_y:

pixel location on map, y axis

Return type:

(pixel_x: int, pixel_y: int)

Convert the given location on the globe to the corresponding pixel locations on the map.

New in version 0.7.0.

convert_screen_to_geographic(pixel_x, pixel_y)
Parameters:
  • pixel_x (int) – pixel location on map, x axis

  • pixel_y (int) – pixel location on map, y axis

Returns:

location

Return type:

pt: OsmGpsMap.MapPoint

Convert the given pixel location on the map into corresponding location on the globe

New in version 0.7.0.

download_cancel_all()

Cancels all tiles currently being downloaded. Typically used if you wish to cacel a large number of tiles queued using OsmGpsMap.Map.download_maps()

New in version 0.7.0.

download_maps(pt1, pt2, zoom_start, zoom_end)
Parameters:

Downloads all tiles over the supplied zoom range in the rectangular region specified by pt1 (north west corner) to pt2 (south east corner)

get_bbox()
Returns:

pt1:

point to be filled with the top left location

pt2:

point to be filled with the bottom right location

Return type:

(pt1: OsmGpsMap.MapPoint, pt2: OsmGpsMap.MapPoint)

Returns the geographic locations of the bounding box describing the contents of the current window, i.e the top left and bottom right corners.

get_event_location(event)
Parameters:

event (Gdk.EventButton) – A #GtkEventButton that occured on the map

Returns:

The point on the globe corresponding to the click

Return type:

OsmGpsMap.MapPoint

A convenience function for getting the geographic location of events, such as mouse clicks, on the map

Free returned point with GLib.free

New in version 0.7.0.

get_scale()
Returns:

the scale of the map at the center, in meters/pixel.

Return type:

float

Get the scale of the map at the center, in meters/pixel.

gps_add(latitude, longitude, heading)
Parameters:

Set current GPS point to given lat/lon point with given heading. If record-trip-history is set, add point to trip history

New in version 0.7.0.

gps_clear()

Clear GPS track history

New in version 0.7.0.

gps_get_track()
Returns:

The OsmGpsMap.MapTrack of the internal GPS track, i.e. that which is modified when calling OsmGpsMap.Map.gps_add(). You must not free this.

Return type:

OsmGpsMap.MapTrack

Get internal GPS track history

New in version 0.7.0.

image_add(latitude, longitude, image)
Parameters:
Returns:

A OsmGpsMap.MapImage representing the added pixbuf

Return type:

OsmGpsMap.MapImage

Creates OsmGpsMapImage with given params and adds it to map images

New in version 0.7.0.

image_add_with_alignment(latitude, longitude, image, xalign, yalign)
Parameters:
  • latitude (float) – latitude in degrees

  • longitude (float) – longitude in degrees

  • image (GdkPixbuf.Pixbuf) – Image pixbuf

  • xalign (float) – x-align of image

  • yalign (float) – y-align of image

Returns:

A OsmGpsMap.MapImage representing the added pixbuf

Return type:

OsmGpsMap.MapImage

Creates OsmGpsMapImage with given params and adds it to map images

New in version 0.7.0.

image_add_with_alignment_z(latitude, longitude, image, xalign, yalign, zorder)
Parameters:
  • latitude (float) – latitude in degrees

  • longitude (float) – longitude in degrees

  • image (GdkPixbuf.Pixbuf) – Image pixbuf

  • xalign (float) – x-align of image

  • yalign (float) – y-align of image

  • zorder (int) – z-order of image

Returns:

A OsmGpsMap.MapImage representing the added pixbuf

Return type:

OsmGpsMap.MapImage

Creates OsmGpsMapImage with given params and adds it to map images

New in version 0.7.4.

image_add_z(latitude, longitude, image, zorder)
Parameters:
  • latitude (float) – latitude in degrees

  • longitude (float) – longitude in degrees

  • image (GdkPixbuf.Pixbuf) – Image pixbuf

  • zorder (int) – z-order of image

Returns:

A OsmGpsMap.MapImage representing the added pixbuf

Return type:

OsmGpsMap.MapImage

Creates OsmGpsMapImage with given params and adds it to map images

New in version 0.7.4.

image_remove(image)
Parameters:

image (OsmGpsMap.MapImage) – a OsmGpsMapImage to remove

Returns:

true if image was on list of images

Return type:

bool

Remove image from list of images

New in version 0.7.0.

image_remove_all()

Remove all images from map

New in version 0.7.0.

layer_add(layer)
Parameters:

layer (OsmGpsMap.MapLayer) – a OsmGpsMap.MapLayer object

Add layer to map

New in version 0.7.0.

layer_remove(layer)
Parameters:

layer (OsmGpsMap.MapLayer) – a OsmGpsMap.MapLayer object

Returns:

whether layer was found and removed

Return type:

bool

Remove layer from map

New in version 0.7.0.

layer_remove_all()

Remove all layers from map

New in version 0.7.0.

map_redraw()
Return type:

bool

map_redraw_idle()
polygon_add(poly)
Parameters:

poly (OsmGpsMap.MapPolygon) –

polygon_remove(poly)
Parameters:

poly (OsmGpsMap.MapPolygon) –

Return type:

bool

polygon_remove_all()
scroll(dx, dy)
Parameters:
  • dx (int) – pixels to scroll in NS (positive: scroll nort, negative: scroll south)

  • dy (int) – pixels to scroll in EW (positive: scroll east, negative: scroll west)

Scrolls the map by dx, dy pixels (positive north, east)

set_center(latitude, longitude)
Parameters:
  • latitude (float) – latitude in degrees

  • longitude (float) – longitude in degrees

Set map center, does not change zoom level

set_center_and_zoom(latitude, longitude, zoom)
Parameters:
  • latitude (float) – latitude in degrees

  • longitude (float) – longitude in degrees

  • zoom (int) – desired zoom level

Set map center and desired zoom level

New in version 0.7.0.

set_keyboard_shortcut(key, keyval)
Parameters:

Associates a keyboard shortcut with the supplied keyval (as returned by Gdk.keyval_from_name or simiar). The action given in key will be triggered when the corresponding keyval is pressed. By default no keyboard shortcuts are associated.

set_zoom(zoom)
Parameters:

zoom (int) – Desired zoom level

Returns:

zoom level

Return type:

int

Set map zoom to the desired zoom level

set_zoom_offset(zoom_offset)
Parameters:

zoom_offset (int) – tile zoom offset

Set tile zoom offset

track_add(track)
Parameters:

track (OsmGpsMap.MapTrack) – a OsmGpsMapTrack object

Add a track to map

New in version 0.7.0.

track_remove(track)
Parameters:

track (OsmGpsMap.MapTrack) – a OsmGpsMap.MapTrack object

Return type:

bool

Remove given track from map

New in version 0.7.0.

track_remove_all()

Remove all tracks

New in version 0.7.0.

zoom_fit_bbox(latitude1, latitude2, longitude1, longitude2)
Parameters:
  • latitude1 (float) – latitude of 1st point in degrees

  • latitude2 (float) – latitude of 2nd point in degrees

  • longitude1 (float) – longtitude of 1st point in degrees

  • longitude2 (float) – longtitude of 2nd point in degrees

Zoom and center the map so that both points fit inside the window.

New in version 1.1.0.

zoom_in()
Returns:

zoom level

Return type:

int

Zoom in by 1 step

zoom_out()
Returns:

zoom level

Return type:

int

Zoom out by 1 step

do_draw_gps_point(cr) virtual
Parameters:

cr (cairo.Context) –

Signal Details

OsmGpsMap.Map.signals.changed(map)
Signal Name:

changed

Flags:

RUN_FIRST

Parameters:

map (OsmGpsMap.Map) – The object which received the signal

The OsmGpsMap.Map ::changed signal is emitted any time the map zoom or map center is chaged (such as by dragging or zooming).

If you are only interested in the map zoom, then you can simply connect to ::notify::zoom

Property Details

OsmGpsMap.Map.props.auto_center
Name:

auto-center

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, CONSTRUCT

map auto center

OsmGpsMap.Map.props.auto_center_threshold
Name:

auto-center-threshold

Type:

float

Default Value:

0.25

Flags:

READABLE, WRITABLE, CONSTRUCT

the amount of the window the gps point must move before auto centering

OsmGpsMap.Map.props.auto_download
Name:

auto-download

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, CONSTRUCT

map auto download

OsmGpsMap.Map.props.drag_limit
Name:

drag-limit

Type:

int

Default Value:

10

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The number of pixels the user has to move the pointer in order to start dragging

OsmGpsMap.Map.props.gps_track_highlight_radius
Name:

gps-track-highlight-radius

Type:

int

Default Value:

20

Flags:

READABLE, WRITABLE, CONSTRUCT

The radius of the gps point highlight circle

OsmGpsMap.Map.props.gps_track_point_radius
Name:

gps-track-point-radius

Type:

int

Default Value:

5

Flags:

READABLE, WRITABLE, CONSTRUCT

The radius of the gps point inner circle

OsmGpsMap.Map.props.gps_track_width
Name:

gps-track-width

Type:

float

Default Value:

4.0

Flags:

READABLE, WRITABLE, CONSTRUCT

The width of the lines drawn for the gps track

OsmGpsMap.Map.props.image_format
Name:

image-format

Type:

str

Default Value:

'png'

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The map source tile repository image format (jpg, png)

OsmGpsMap.Map.props.latitude
Name:

latitude

Type:

float

Default Value:

0.0

Flags:

READABLE

Latitude in degrees

OsmGpsMap.Map.props.longitude
Name:

longitude

Type:

float

Default Value:

0.0

Flags:

READABLE

Longitude in degrees

OsmGpsMap.Map.props.map_source
Name:

map-source

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT

A OsmGpsMap.MapSource_t representing the tile repository to use

If you do not wish to use the default map tiles (provided by OpenStreeMap) it is recommened that you set this property at construction, instead of setting OsmGpsMap.Map :repo-uri.

OsmGpsMap.Map.props.map_x
Name:

map-x

Type:

int

Default Value:

890

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Initial map x location

OsmGpsMap.Map.props.map_y
Name:

map-y

Type:

int

Default Value:

515

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Initial map y location

OsmGpsMap.Map.props.max_zoom
Name:

max-zoom

Type:

int

Default Value:

20

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Maximum zoom level

OsmGpsMap.Map.props.min_zoom
Name:

min-zoom

Type:

int

Default Value:

1

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Minimum zoom level

OsmGpsMap.Map.props.proxy_uri
Name:

proxy-uri

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

HTTP proxy uri or None

OsmGpsMap.Map.props.record_trip_history
Name:

record-trip-history

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, CONSTRUCT

should all gps points be recorded in a trip history

OsmGpsMap.Map.props.repo_uri
Name:

repo-uri

Type:

str

Default Value:

'https://tile.openstreetmap.org/#Z/#X/#Y.png'

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

A URI string which defines the location and format to fetch tiles for the map. The string is of the format “http://tile.openstreetmap.org/#Z/#X/#Y.png”. Characters that begin with # are treated as tokens and replaced according to the following rules;

<itemizedlist> <listitem> <para> \#X - X-tile, slippy map format </para> </listitem> <listitem> <para> \#Y - Y-tile, slippy map format, mercator projection </para> </listitem> <listitem> <para> \#Z - Zoom level, where min_zoom &gt;= zoom &lt;= max_zoom </para> </listitem> <listitem> <para> \#S - Zoom level, where -max_zoom &gt;= (zoom-max_zoom) &lt;= min_zoom </para> </listitem> <listitem> <para> \#Q - Quad tree format, set of “qrts” </para> </listitem> <listitem> <para> \#Q0 - Quad tree format, set of “0123” </para> </listitem> <listitem> <para> \#YS - Not Implemented </para> </listitem> <listitem> <para> \#R - Random integer in range [0,4] </para> </listitem> </itemizedlist>

<note> <para> If you do not wish to use the default map tiles (provided by OpenStreeMap) it is recommened that you use one of the predefined map sources, and thus you should construct the map by setting OsmGpsMap.Map :map-source and not OsmGpsMap.Map :repo-uri. The OsmGpsMap.Map :repo-uri property is primarily designed for applications that wish complete control of tile repository management, or wish to use OsmGpsMap.Map with a tile repository it does not explicitly support. </para> </note>

OsmGpsMap.Map.props.show_gps_point
Name:

show-gps-point

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, CONSTRUCT

Controls whether the current gps point is shown on the map. Note that for derived classes that implement the draw_gps_point vfunc, if this property is False

OsmGpsMap.Map.props.show_trip_history
Name:

show-trip-history

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, CONSTRUCT

should the recorded trip history be shown on the map

OsmGpsMap.Map.props.tile_cache
Name:

tile-cache

Type:

str

Default Value:

'auto://'

Flags:

READABLE, WRITABLE, CONSTRUCT

Either a full path or one of the special format URIs OsmGpsMap.MAP_CACHE_DISABLED, OsmGpsMap.MAP_CACHE_AUTO, OsmGpsMap.MAP_CACHE_FRIENDLY. Also see OsmGpsMap.Map :tile-cache-base for a full understanding.

OsmGpsMap.MAP_CACHE_DISABLED disables the on disk tile cache (so all tiles are fetched from the network. OsmGpsMap.MAP_CACHE_AUTO causes the tile cache to be /tile-cache-base/md5(repo-uri), where md5 is the md5sum of OsmGpsMap.Map :repo-uri. OsmGpsMap.MAP_CACHE_FRIENDLY causes the tile cache to be /tile-cache-base/friendlyname(repo-uri).

Any other string is interpreted as a local path, i.e. /path/to/cache

OsmGpsMap.Map.props.tile_cache_base
Name:

tile-cache-base

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The base directory of the tile cache when you have constructed the map with OsmGpsMap.Map :tile-cache set to OsmGpsMap.MAP_CACHE_AUTO or OsmGpsMap.MAP_CACHE_FRIENDLY

The string is interpreted as a local path, i.e. /path/to/cache. If None is supplied, map tiles are cached starting in the users cache directory, (as outlined in the

XDG Base Directory Specification). To get the base directory where map tiles will be cached call OsmGpsMap.Map.get_default_cache_directory()

OsmGpsMap.Map.props.tile_zoom_offset
Name:

tile-zoom-offset

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Number of zoom-levels to upsample tiles

OsmGpsMap.Map.props.tiles_queued
Name:

tiles-queued

Type:

int

Default Value:

0

Flags:

READABLE

The number of tiles currently waiting to download. Connect to ::notify::tiles-queued if you want to be informed when this changes

OsmGpsMap.Map.props.user_agent
Name:

user-agent

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The default user-agent for downloading tiles from the OsmGpsMap.Map :map-source is “libosmgpsmap/VERSION”. The value of OsmGpsMap.Map :user-agent will be appended to it.

New in version 1.2.0.

OsmGpsMap.Map.props.zoom
Name:

zoom

Type:

int

Default Value:

3

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The map zoom level. Connect to ::notify::zoom if you want to be informed when this changes.