![]() |
![]() |
![]() |
OsmGpsMap Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
#include <osm-gps-map.h> 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 gchar * osm_gps_map_get_default_cache_directory (void
); enum OsmGpsMapSource_t; 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
); int osm_gps_map_source_get_min_zoom (OsmGpsMapSource_t source
); int osm_gps_map_source_get_max_zoom (OsmGpsMapSource_t source
); gboolean osm_gps_map_source_is_valid (OsmGpsMapSource_t source
); GtkWidget * osm_gps_map_new (void
); void osm_gps_map_download_maps (OsmGpsMap *map
,OsmGpsMapPoint *pt1
,OsmGpsMapPoint *pt2
,int zoom_start
,int zoom_end
); void osm_gps_map_download_cancel_all (OsmGpsMap *map
); void osm_gps_map_get_bbox (OsmGpsMap *map
,OsmGpsMapPoint *pt1
,OsmGpsMapPoint *pt2
); 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
); int osm_gps_map_set_zoom (OsmGpsMap *map
,int zoom
); int osm_gps_map_zoom_in (OsmGpsMap *map
); int osm_gps_map_zoom_out (OsmGpsMap *map
); void osm_gps_map_scroll (OsmGpsMap *map
,gint dx
,gint dy
); float osm_gps_map_get_scale (OsmGpsMap *map
); enum OsmGpsMapKey_t; void osm_gps_map_set_keyboard_shortcut (OsmGpsMap *map
,OsmGpsMapKey_t key
,guint keyval
); OsmGpsMapPoint * osm_gps_map_get_event_location (OsmGpsMap *map
,GdkEventButton *event
); void osm_gps_map_convert_geographic_to_screen (OsmGpsMap *map
,OsmGpsMapPoint *pt
,gint *pixel_x
,gint *pixel_y
); void osm_gps_map_convert_screen_to_geographic (OsmGpsMap *map
,gint pixel_x
,gint pixel_y
,OsmGpsMapPoint *pt
); void osm_gps_map_gps_add (OsmGpsMap *map
,float latitude
,float longitude
,float heading
); void osm_gps_map_gps_clear (OsmGpsMap *map
); OsmGpsMapTrack * osm_gps_map_gps_get_track (OsmGpsMap *map
); void osm_gps_map_track_add (OsmGpsMap *map
,OsmGpsMapTrack *track
); gboolean osm_gps_map_track_remove (OsmGpsMap *map
,OsmGpsMapTrack *track
); void osm_gps_map_track_remove_all (OsmGpsMap *map
); OsmGpsMapImage * osm_gps_map_image_add (OsmGpsMap *map
,float latitude
,float longitude
,GdkPixbuf *image
); OsmGpsMapImage * osm_gps_map_image_add_with_alignment (OsmGpsMap *map
,float latitude
,float longitude
,GdkPixbuf *image
,float xalign
,float yalign
); gboolean osm_gps_map_image_remove (OsmGpsMap *map
,OsmGpsMapImage *image
); void osm_gps_map_image_remove_all (OsmGpsMap *map
); void osm_gps_map_layer_add (OsmGpsMap *map
,OsmGpsMapLayer *layer
); gboolean osm_gps_map_layer_remove (OsmGpsMap *map
,OsmGpsMapLayer *layer
); void osm_gps_map_layer_remove_all (OsmGpsMap *map
);
GObject +----GInitiallyUnowned +----GtkObject +----GtkWidget +----GtkDrawingArea +----OsmGpsMap
"auto-center" gboolean : Read / Write / Construct "auto-center-threshold" gfloat : Read / Write / Construct "auto-download" gboolean : Read / Write / Construct "drag-limit" gint : Read / Write / Construct Only "gps-track-highlight-radius" gint : Read / Write / Construct "gps-track-point-radius" gint : Read / Write / Construct "gps-track-width" gfloat : Read / Write / Construct "image-format" gchar* : Read / Write / Construct Only "latitude" gfloat : Read "longitude" gfloat : Read "map-source" gint : Read / Write / Construct "map-x" gint : Read / Write / Construct Only "map-y" gint : Read / Write / Construct Only "max-zoom" gint : Read / Write / Construct Only "min-zoom" gint : Read / Write / Construct Only "proxy-uri" gchar* : Read / Write / Construct Only "record-trip-history" gboolean : Read / Write / Construct "repo-uri" gchar* : Read / Write / Construct Only "show-gps-point" gboolean : Read / Write / Construct "show-trip-history" gboolean : Read / Write / Construct "tile-cache" gchar* : Read / Write / Construct "tile-cache-base" gchar* : Read / Write / Construct Only "tile-cache-is-full-path" gboolean : Read / Write "tile-zoom-offset" gint : Read / Write / Construct Only "tiles-queued" gint : Read "zoom" gint : Read / Write / Construct Only
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 OpenStreetMap
Example 1. Showing a map
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
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 CloudMade then you can also pass a specially formatted string to "repo-uri".
Example 3. Map using custom CloudMade map and on screen display
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; }
struct OsmGpsMapClass { GtkDrawingAreaClass parent_class; void (*draw_gps_point) (OsmGpsMap *map, GdkDrawable *drawable); };
gchar * osm_gps_map_get_default_cache_directory
(void
);
Returns : |
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. |
typedef enum { OSM_GPS_MAP_SOURCE_NULL, OSM_GPS_MAP_SOURCE_OPENSTREETMAP, OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER, OSM_GPS_MAP_SOURCE_OPENAERIALMAP, OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE, OSM_GPS_MAP_SOURCE_OPENCYCLEMAP, OSM_GPS_MAP_SOURCE_OSM_PUBLIC_TRANSPORT, OSM_GPS_MAP_SOURCE_GOOGLE_STREET, OSM_GPS_MAP_SOURCE_GOOGLE_SATELLITE, OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID, OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_STREET, OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_SATELLITE, OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_HYBRID, OSM_GPS_MAP_SOURCE_YAHOO_STREET, OSM_GPS_MAP_SOURCE_YAHOO_SATELLITE, OSM_GPS_MAP_SOURCE_YAHOO_HYBRID, OSM_GPS_MAP_SOURCE_OSMC_TRAILS, OSM_GPS_MAP_SOURCE_LAST } OsmGpsMapSource_t;
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 OpenStreetMap
See the properties description for more information about construction
parameters than could be passed to g_object_new()
Returns : |
a newly created OsmGpsMap object. |
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
);
|
point to be filled with the top left location |
|
point to be filled with the bottom right location |
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)
float osm_gps_map_get_scale (OsmGpsMap *map
);
Returns : |
the scale of the map at the center, in meters/pixel. |
typedef enum { OSM_GPS_MAP_KEY_FULLSCREEN, OSM_GPS_MAP_KEY_ZOOMIN, OSM_GPS_MAP_KEY_ZOOMOUT, OSM_GPS_MAP_KEY_UP, OSM_GPS_MAP_KEY_DOWN, OSM_GPS_MAP_KEY_LEFT, OSM_GPS_MAP_KEY_RIGHT, OSM_GPS_MAP_KEY_MAX } OsmGpsMapKey_t;
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.
|
a OsmGpsMapKey_t |
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
|
A GtkEventButton that occured on the map |
Returns : |
The point on the globe corresponding to the click. [transfer full] |
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.
|
location |
|
pixel location on map, x axis. [out] |
|
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 location on map, x axis |
|
pixel location on map, y axis |
|
location. [out] |
Since 0.7.0
void osm_gps_map_gps_add (OsmGpsMap *map
,float latitude
,float longitude
,float heading
);
|
degrees |
|
degrees |
|
degrees or OSM_GPS_MAP_INVALID to disable showing heading |
Since 0.7.0
OsmGpsMapTrack * osm_gps_map_gps_get_track (OsmGpsMap *map
);
Returns : |
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
);
Returns : |
A OsmGpsMapImage representing the added pixbuf. [transfer full] |
Since 0.7.0
OsmGpsMapImage * osm_gps_map_image_add_with_alignment (OsmGpsMap *map
,float latitude
,float longitude
,GdkPixbuf *image
,float xalign
,float yalign
);
Returns : |
A OsmGpsMapImage representing the added pixbuf. [transfer full] |
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
);
|
a OsmGpsMapLayer object |
Since 0.7.0
gboolean osm_gps_map_layer_remove (OsmGpsMap *map
,OsmGpsMapLayer *layer
);
|
a OsmGpsMapLayer object |
Since 0.7.0
"auto-center"
property "auto-center" gboolean : Read / Write / Construct
map auto center.
Default value: TRUE
"auto-center-threshold"
property "auto-center-threshold" gfloat : Read / Write / Construct
the amount of the window the gps point must move before auto centering.
Allowed values: [0,1]
Default value: 0.25
"auto-download"
property "auto-download" gboolean : Read / Write / Construct
map auto download.
Default value: TRUE
"drag-limit"
property "drag-limit" gint : Read / Write / Construct Only
The number of pixels the user has to move the pointer in order to start dragging.
Allowed values: >= 0
Default value: 10
"gps-track-highlight-radius"
property "gps-track-highlight-radius" gint : Read / Write / Construct
The radius of the gps point highlight circle.
Allowed values: >= 0
Default value: 20
"gps-track-point-radius"
property "gps-track-point-radius" gint : Read / Write / Construct
The radius of the gps point inner circle.
Allowed values: >= 0
Default value: 5
"gps-track-width"
property "gps-track-width" gfloat : Read / Write / Construct
The width of the lines drawn for the gps track.
Allowed values: [1,100]
Default value: 4
"image-format"
property "image-format" gchar* : Read / Write / Construct Only
The map source tile repository image format (jpg, png).
Default value: "png"
"latitude"
property "latitude" gfloat : Read
Latitude in degrees.
Allowed values: [-90,90]
Default value: 0
"longitude"
property "longitude" gfloat : Read
Longitude in degrees.
Allowed values: [-180,180]
Default value: 0
"map-source"
property "map-source" gint : Read / Write / Construct
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".
Allowed values: >= -1
Default value: -1
"map-x"
property "map-x" gint : Read / Write / Construct Only
Initial map x location.
Default value: 890
"map-y"
property "map-y" gint : Read / Write / Construct Only
Initial map y location.
Default value: 515
"max-zoom"
property "max-zoom" gint : Read / Write / Construct Only
Maximum zoom level.
Allowed values: [0,20]
Default value: 18
"min-zoom"
property "min-zoom" gint : Read / Write / Construct Only
Minimum zoom level.
Allowed values: [0,20]
Default value: 1
"proxy-uri"
property "proxy-uri" gchar* : Read / Write / Construct Only
HTTP proxy uri or NULL.
Default value: NULL
"record-trip-history"
property "record-trip-history" gboolean : Read / Write / Construct
should all gps points be recorded in a trip history.
Default value: TRUE
"repo-uri"
property "repo-uri" gchar* : Read / Write / 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;
#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.
Default value: "http://tile.openstreetmap.org/#Z/#X/#Y.png"
"show-gps-point"
property "show-gps-point" gboolean : Read / Write / 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
Default value: TRUE
"show-trip-history"
property "show-trip-history" gboolean : Read / Write / Construct
should the recorded trip history be shown on the map.
Default value: TRUE
"tile-cache"
property "tile-cache" gchar* : Read / Write / Construct
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
Default value: "auto://"
"tile-cache-base"
property "tile-cache-base" gchar* : Read / Write / Construct Only
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 the
base directory where map tiles will be cached call
osm_gps_map_get_default_cache_directory()
Default value: NULL
"tile-cache-is-full-path"
property "tile-cache-is-full-path" gboolean : Read / Write
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
Default value: FALSE
"tile-zoom-offset"
property "tile-zoom-offset" gint : Read / Write / Construct Only
Number of zoom-levels to upsample tiles.
Allowed values: [0,10]
Default value: 0
"tiles-queued"
property "tiles-queued" gint : Read
The number of tiles currently waiting to download. Connect to ::notify::tiles-queued if you want to be informed when this changes
Default value: 0
"changed"
signalvoid user_function (OsmGpsMap *arg0,
gpointer user_data) : Run First
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
|
user data set when the signal handler was connected. |