Top | ![]() |
![]() |
![]() |
![]() |
gboolean | auto-center | Read / Write / Construct |
gfloat | auto-center-threshold | Read / Write / Construct |
gboolean | auto-download | Read / Write / Construct |
gint | drag-limit | Read / Write / Construct Only |
gint | gps-track-highlight-radius | Read / Write / Construct |
gint | gps-track-point-radius | Read / Write / Construct |
gfloat | gps-track-width | Read / Write / Construct |
gchar * | image-format | Read / Write / Construct Only |
gfloat | latitude | Read |
gfloat | longitude | Read |
gint | map-source | Read / Write / Construct |
gint | map-x | Read / Write / Construct Only |
gint | map-y | Read / Write / Construct Only |
gint | max-zoom | Read / Write / Construct Only |
gint | min-zoom | Read / Write / Construct Only |
gchar * | proxy-uri | Read / Write / Construct Only |
gboolean | record-trip-history | Read / Write / Construct |
gchar * | repo-uri | Read / Write / Construct Only |
gboolean | show-gps-point | Read / Write / Construct |
gboolean | show-trip-history | Read / Write / Construct |
gchar * | tile-cache | Read / Write / Construct |
gchar * | tile-cache-base | Read / Write / Construct Only |
gboolean | tile-cache-is-full-path | Read / Write |
gint | tile-zoom-offset | Read / Write / Construct Only |
gint | tiles-queued | Read |
gint | zoom | Read / Write / Construct Only |
struct | OsmGpsMap |
struct | OsmGpsMapClass |
#define | OSM_GPS_MAP_INVALID |
#define | OSM_GPS_MAP_CACHE_DISABLED |
#define | OSM_GPS_MAP_CACHE_AUTO |
#define | OSM_GPS_MAP_CACHE_FRIENDLY |
enum | OsmGpsMapSource_t |
enum | OsmGpsMapKey_t |
GObject ╰── GInitiallyUnowned ╰── GtkObject ╰── GtkWidget ╰── GtkDrawingArea ╰── OsmGpsMap
OsmGpsMap is a widget for displaying a map, optionally overlaid with a track(s) of GPS co-ordinates, images, points of interest or on screen display controls. OsmGpsMap downloads (and caches for offline use) map data from a number of websites, including
OpenStreetMapExample 1. Showing a map
1 2 3 4 5 6 7 8 9 10 11 12 13 |
int main (int argc, char **argv) { g_thread_init(NULL); gtk_init (&argc, &argv); GtkWidget *map = osm_gps_map_new (); GtkWidget *w = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_add (GTK_CONTAINER(w), map); gtk_widget_show_all (w); gtk_main (); return 0; } |
OsmGpsMap allows great flexibility in customizing how the map tiles are cached, see “tile-cache-base” and “tile-cache” for more information.
A number of different map sources are supported, see OsmGpsMapSource_t. The
default source, OSM_GPS_MAP_SOURCE_OPENSTREETMAP
always works. Other sources,
particular those from proprietary providers may work occasionally, and then
cease to work. To check if a source is supported for the given version of
this library, call osm_gps_map_source_is_valid()
.
Example 2. Map with custom source and cache dir
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
int main (int argc, char **argv) { g_thread_init(NULL); gtk_init (&argc, &argv); OsmGpsMapSource_t source = OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_SATELLITE; if ( !osm_gps_map_source_is_valid(source) ) return 1; GtkWidget *map = g_object_new (OSM_TYPE_GPS_MAP, "map-source", source, "tile-cache", "/tmp/", NULL); GtkWidget *w = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_add (GTK_CONTAINER(w), map); gtk_widget_show_all (w); gtk_main (); return 0; } |
Finally, if you wish to use a custom map source not supported by OsmGpsMap, such as a custom map created with
CloudMadethen you can also pass a specially formatted string to “repo-uri”.
Example 3. Map using custom CloudMade map and on screen display
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
int main (int argc, char **argv) { g_thread_init(NULL); gtk_init (&argc, &argv); const gchar *cloudmate = "http://a.tile.cloudmade.com/YOUR_API_KEY/1/256/#Z/#X/#Y.png"; GtkWidget *map = g_object_new (OSM_TYPE_GPS_MAP, "repo-uri", cloudmate, NULL); OsmGpsMapOsd *osd = osm_gps_map_osd_new (); GtkWidget *w = gtk_window_new (GTK_WINDOW_TOPLEVEL); osm_gps_map_layer_add (OSM_GPS_MAP(map), OSM_GPS_MAP_LAYER(osd)); gtk_container_add (GTK_CONTAINER(w), map); gtk_widget_show_all (w); gtk_main (); return 0; } |
gchar *
osm_gps_map_get_default_cache_directory
(void
);
the default cache directory for the library, that is the base directory to which the full cache path is appended. If “tile-cache-base” is omitted from the constructor then this value is used.
const char *
osm_gps_map_source_get_friendly_name (OsmGpsMapSource_t source
);
const char *
osm_gps_map_source_get_repo_uri (OsmGpsMapSource_t source
);
const char *
osm_gps_map_source_get_image_format (OsmGpsMapSource_t source
);
GtkWidget *
osm_gps_map_new (void
);
Returns a new OsmGpsMap object, defaults to showing data from
OpenStreetMapSee the properties description for more information about construction
parameters than could be passed to g_object_new()
void osm_gps_map_download_maps (OsmGpsMap *map
,OsmGpsMapPoint *pt1
,OsmGpsMapPoint *pt2
,int zoom_start
,int zoom_end
);
Downloads all tiles over the supplied zoom range in the rectangular region specified by pt1 (north west corner) to pt2 (south east corner)
void
osm_gps_map_download_cancel_all (OsmGpsMap *map
);
Cancels all tiles currently being downloaded. Typically used if you wish to
cacel a large number of tiles queued using osm_gps_map_download_maps()
Since: 0.7.0
void osm_gps_map_get_bbox (OsmGpsMap *map
,OsmGpsMapPoint *pt1
,OsmGpsMapPoint *pt2
);
Returns the geographic locations of the bounding box describing the contents of the current window, i.e the top left and bottom right corners.
void osm_gps_map_set_center (OsmGpsMap *map
,float latitude
,float longitude
);
void osm_gps_map_set_center_and_zoom (OsmGpsMap *map
,float latitude
,float longitude
,int zoom
);
Since: 0.7.0
void osm_gps_map_scroll (OsmGpsMap *map
,gint dx
,gint dy
);
Scrolls the map by dx
, dy
pixels (positive north, east)
void osm_gps_map_set_keyboard_shortcut (OsmGpsMap *map
,OsmGpsMapKey_t key
,guint keyval
);
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.
OsmGpsMapPoint * osm_gps_map_get_event_location (OsmGpsMap *map
,GdkEventButton *event
);
A convenience function for getting the geographic location of events, such as mouse clicks, on the map
Since: 0.7.0
void osm_gps_map_convert_geographic_to_screen (OsmGpsMap *map
,OsmGpsMapPoint *pt
,gint *pixel_x
,gint *pixel_y
);
Convert the given location on the globe to the corresponding pixel locations on the map.
pt |
location |
|
pixel_x |
pixel location on map, x axis. |
[out] |
pixel_y |
pixel location on map, y axis. |
[out] |
Since: 0.7.0
void osm_gps_map_convert_screen_to_geographic (OsmGpsMap *map
,gint pixel_x
,gint pixel_y
,OsmGpsMapPoint *pt
);
Convert the given pixel location on the map into corresponding location on the globe
pixel_x |
pixel location on map, x axis |
|
pixel_y |
pixel location on map, y axis |
|
pt |
location. |
[out] |
Since: 0.7.0
void osm_gps_map_gps_add (OsmGpsMap *map
,float latitude
,float longitude
,float heading
);
latitude |
degrees |
|
longitude |
degrees |
|
heading |
degrees or OSM_GPS_MAP_INVALID to disable showing heading |
Since: 0.7.0
OsmGpsMapTrack *
osm_gps_map_gps_get_track (OsmGpsMap *map
);
The OsmGpsMapTrack of the internal GPS track,
i.e. that which is modified when calling osm_gps_map_gps_add()
. You must
not free this.
[transfer none]
Since: 0.7.0
void osm_gps_map_track_add (OsmGpsMap *map
,OsmGpsMapTrack *track
);
Since: 0.7.0
gboolean osm_gps_map_track_remove (OsmGpsMap *map
,OsmGpsMapTrack *track
);
Since: 0.7.0
OsmGpsMapImage * osm_gps_map_image_add (OsmGpsMap *map
,float latitude
,float longitude
,GdkPixbuf *image
);
Since: 0.7.0
OsmGpsMapImage * osm_gps_map_image_add_with_alignment (OsmGpsMap *map
,float latitude
,float longitude
,GdkPixbuf *image
,float xalign
,float yalign
);
Since: 0.7.0
gboolean osm_gps_map_image_remove (OsmGpsMap *map
,OsmGpsMapImage *image
);
Since: 0.7.0
void osm_gps_map_layer_add (OsmGpsMap *map
,OsmGpsMapLayer *layer
);
Since: 0.7.0
gboolean osm_gps_map_layer_remove (OsmGpsMap *map
,OsmGpsMapLayer *layer
);
Since: 0.7.0
struct OsmGpsMapClass { GtkDrawingAreaClass parent_class; void (*draw_gps_point) (OsmGpsMap *map, GdkDrawable *drawable); };
“auto-center”
property “auto-center” gboolean
map auto center.
Owner: OsmGpsMap
Flags: Read / Write / Construct
Default value: TRUE
“auto-center-threshold”
property “auto-center-threshold” gfloat
the amount of the window the gps point must move before auto centering.
Owner: OsmGpsMap
Flags: Read / Write / Construct
Allowed values: [0,1]
Default value: 0.25
“auto-download”
property “auto-download” gboolean
map auto download.
Owner: OsmGpsMap
Flags: Read / Write / Construct
Default value: TRUE
“drag-limit”
property “drag-limit” gint
The number of pixels the user has to move the pointer in order to start dragging.
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Allowed values: >= 0
Default value: 10
“gps-track-highlight-radius”
property “gps-track-highlight-radius” gint
The radius of the gps point highlight circle.
Owner: OsmGpsMap
Flags: Read / Write / Construct
Allowed values: >= 0
Default value: 20
“gps-track-point-radius”
property “gps-track-point-radius” gint
The radius of the gps point inner circle.
Owner: OsmGpsMap
Flags: Read / Write / Construct
Allowed values: >= 0
Default value: 5
“gps-track-width”
property “gps-track-width” gfloat
The width of the lines drawn for the gps track.
Owner: OsmGpsMap
Flags: Read / Write / Construct
Allowed values: [1,100]
Default value: 4
“image-format”
property “image-format” gchar *
The map source tile repository image format (jpg, png).
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Default value: "png"
“latitude”
property “latitude” gfloat
Latitude in degrees.
Owner: OsmGpsMap
Flags: Read
Allowed values: [-90,90]
Default value: 0
“longitude”
property “longitude” gfloat
Longitude in degrees.
Owner: OsmGpsMap
Flags: Read
Allowed values: [-180,180]
Default value: 0
“map-source”
property “map-source” gint
A OsmGpsMapSource_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 “repo-uri”.
Owner: OsmGpsMap
Flags: Read / Write / Construct
Allowed values: >= -1
Default value: -1
“map-x”
property “map-x” gint
Initial map x location.
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Default value: 890
“map-y”
property “map-y” gint
Initial map y location.
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Default value: 515
“max-zoom”
property “max-zoom” gint
Maximum zoom level.
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Allowed values: [0,20]
Default value: 18
“min-zoom”
property “min-zoom” gint
Minimum zoom level.
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Allowed values: [0,20]
Default value: 1
“proxy-uri”
property “proxy-uri” gchar *
HTTP proxy uri or NULL.
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Default value: NULL
“record-trip-history”
property “record-trip-history” gboolean
should all gps points be recorded in a trip history.
Owner: OsmGpsMap
Flags: Read / Write / Construct
Default value: TRUE
“repo-uri”
property “repo-uri” gchar *
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;
#X - X-tile, slippy map format
#Y - Y-tile, slippy map format, mercator projection
#Z - Zoom level, where min_zoom >= zoom <= max_zoom
#S - Zoom level, where -max_zoom >= (zoom-max_zoom) <= min_zoom
#Q - Quad tree format, set of "qrts"
#Q0 - Quad tree format, set of "0123"
#YS - Not Implemented
#R - Random integer in range [0,4]
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 “map-source” and not “repo-uri”. The “repo-uri” property is primarily designed for applications that wish complete control of tile repository management, or wish to use OsmGpsMap with a tile repository it does not explicitly support.
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Default value: "http://tile.openstreetmap.org/#Z/#X/#Y.png"
“show-gps-point”
property “show-gps-point” gboolean
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
Owner: OsmGpsMap
Flags: Read / Write / Construct
Default value: TRUE
“show-trip-history”
property “show-trip-history” gboolean
should the recorded trip history be shown on the map.
Owner: OsmGpsMap
Flags: Read / Write / Construct
Default value: TRUE
“tile-cache”
property “tile-cache” gchar *
Either a full path or one of the special format URIs OSM_GPS_MAP_CACHE_DISABLED, OSM_GPS_MAP_CACHE_AUTO, OSM_GPS_MAP_CACHE_FRIENDLY. Also see “tile-cache-base” for a full understanding.
OSM_GPS_MAP_CACHE_DISABLED disables the on disk tile cache (so all tiles are fetched from the network. OSM_GPS_MAP_CACHE_AUTO causes the tile cache to be /tile-cache-base/md5(repo-uri), where md5 is the md5sum of “repo-uri”. OSM_GPS_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
Owner: OsmGpsMap
Flags: Read / Write / Construct
Default value: "auto://"
“tile-cache-base”
property “tile-cache-base” gchar *
The base directory of the tile cache when you have constructed the map with “tile-cache” set to OSM_GPS_MAP_CACHE_AUTO or OSM_GPS_MAP_CACHE_FRIENDLY
The string is interpreted as a local path, i.e. /path/to/cache. If NULL is supplied, map tiles are cached starting in the users cache directory, (as outlined in the
XDG Base Directory Specification). To get thebase directory where map tiles will be cached call
osm_gps_map_get_default_cache_directory()
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Default value: NULL
“tile-cache-is-full-path”
property “tile-cache-is-full-path” gboolean
OsmGpsMap:tile-cache-is-full-path
is deprecated and should not be used in newly-written code.
Use “tile-cache” and “tile-cache-base” instead
Owner: OsmGpsMap
Flags: Read / Write
Default value: FALSE
“tile-zoom-offset”
property “tile-zoom-offset” gint
Number of zoom-levels to upsample tiles.
Owner: OsmGpsMap
Flags: Read / Write / Construct Only
Allowed values: [0,10]
Default value: 0
“tiles-queued”
property “tiles-queued” gint
The number of tiles currently waiting to download. Connect to ::notify::tiles-queued if you want to be informed when this changes
Owner: OsmGpsMap
Flags: Read
Default value: 0
“changed”
signalvoid user_function (OsmGpsMap *osmgpsmap, gpointer user_data)
The “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
Flags: Run First