![]() |
![]() |
![]() |
libchamplain Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
ChamplainViewChamplainView — A ClutterActor to display maps |
enum ChamplainScrollMode; ChamplainView; ClutterActor * champlain_view_new (void); void champlain_view_center_on (ChamplainView *view, gdouble latitude, gdouble longitude); void champlain_view_go_to (ChamplainView *view, gdouble latitude, gdouble longitude); void champlain_view_stop_go_to (ChamplainView *view); void champlain_view_zoom_in (ChamplainView *champlainView); void champlain_view_zoom_out (ChamplainView *champlainView); void champlain_view_set_zoom_level (ChamplainView *champlainView, gint zoom_level); void champlain_view_set_min_zoom_level (ChamplainView *view, gint zoom_level); void champlain_view_set_max_zoom_level (ChamplainView *view, gint zoom_level); void champlain_view_ensure_visible (ChamplainView *view, gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2, gboolean animate); void champlain_view_ensure_markers_visible (ChamplainView *view, ChamplainBaseMarker *markers[], gboolean animate); void champlain_view_set_map_source (ChamplainView *champlainView, ChamplainMapSource *map_source); void champlain_view_set_size (ChamplainView *view, guint width, guint height); void champlain_view_set_decel_rate (ChamplainView *view, gdouble rate); void champlain_view_set_scroll_mode (ChamplainView *view, ChamplainScrollMode mode); void champlain_view_set_keep_center_on_resize (ChamplainView *view, gboolean value); void champlain_view_set_show_license (ChamplainView *view, gboolean value); void champlain_view_set_zoom_on_double_click (ChamplainView *view, gboolean value); void champlain_view_add_layer (ChamplainView *champlainView, ChamplainLayer *layer); gboolean champlain_view_get_coords_from_event (ChamplainView *view, ClutterEvent *event, gdouble *lat, gdouble *lon); gboolean champlain_view_get_coords_at (ChamplainView *view, guint x, guint y, gdouble *lat, gdouble *lon);
GObject +----GInitiallyUnowned +----ClutterActor +----ClutterGroup +----ChamplainView
"decel-rate" gdouble : Read / Write "keep-center-on-resize" gboolean : Read / Write "latitude" gdouble : Read / Write "longitude" gdouble : Read / Write "map-source" ChamplainMapSource* : Read / Write "max-zoom-level" gint : Read / Write "min-zoom-level" gint : Read / Write "scroll-mode" ChamplainScrollMode : Read / Write "show-license" gboolean : Read / Write "state" ChamplainState : Read "zoom-level" gint : Read / Write "zoom-on-double-click" gboolean : Read / Write
The ChamplainView is a ClutterActor to display maps. It supports two modes of scrolling:
Push: the normal behavior where the maps doesn't move after the user stopped scrolling;
Kinetic: the iPhone-like behavior where the maps decelerate after the user stopped scrolling.
You can use the same ChamplainView to display many types of maps. In Champlain they are called map sources. You can change the map-source property at anytime to replace the current displayed map.
The maps are downloaded from Internet from open maps sources (like OpenStreetMap). Maps are divided in tiles for each zoom level. When a tile is requested, ChamplainView will first check if it is in cache (in the user's cache dir under champlain). If an error occurs during download, an error tile will be displayed.
The button-press-event and button-release-event signals are emitted each
time a mouse button is pressed on the view
. Coordinates can be converted
with champlain_view_get_coords_from_event.
typedef enum { CHAMPLAIN_SCROLL_MODE_PUSH, CHAMPLAIN_SCROLL_MODE_KINETIC } ChamplainScrollMode;
void champlain_view_center_on (ChamplainView *view, gdouble latitude, gdouble longitude);
Centers the map on these coordinates.
|
a ChamplainView |
|
the longitude to center the map at |
|
the longitude to center the map at |
Since 0.1
void champlain_view_go_to (ChamplainView *view, gdouble latitude, gdouble longitude);
Move from the current position to these coordinates. All tiles in the intermediate view WILL be loaded!
|
a ChamplainView |
|
the longitude to center the map at |
|
the longitude to center the map at |
Since 0.4
void champlain_view_stop_go_to (ChamplainView *view);
Stop the go to animation. The view will stay where it was when the animation was stopped.
|
a ChamplainView |
Since 0.4
void champlain_view_zoom_in (ChamplainView *champlainView);
Zoom in the map by one level.
|
Since 0.1
void champlain_view_zoom_out (ChamplainView *champlainView);
Zoom out the map by one level.
|
Since 0.1
void champlain_view_set_zoom_level (ChamplainView *champlainView, gint zoom_level);
Changes the current zoom level
|
|
|
a gint |
Since 0.4
void champlain_view_set_min_zoom_level (ChamplainView *view, gint zoom_level);
Changes the lowest allowed zoom level
|
a ChamplainView |
|
Since 0.4
void champlain_view_set_max_zoom_level (ChamplainView *view, gint zoom_level);
Changes the highest allowed zoom level
|
a ChamplainView |
|
Since 0.4
void champlain_view_ensure_visible (ChamplainView *view, gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2, gboolean animate);
Changes the map's zoom level and center to make sure the two given positions are visible
|
a ChamplainView |
|
the latitude of position 1 |
|
the longitude of position 1 |
|
the latitude of position 2 |
|
the longitude of position 2 |
|
Since 0.4
void champlain_view_ensure_markers_visible (ChamplainView *view, ChamplainBaseMarker *markers[], gboolean animate);
Changes the map's zoom level and center to make sure those markers are visible.
FIXME: This doesn't take into account the marker's actor size yet
|
a ChamplainView |
|
a NULL terminated array of ChamplainMarkers |
|
Since 0.4
void champlain_view_set_map_source (ChamplainView *champlainView, ChamplainMapSource *map_source);
Changes the currently used map source. g_object_unref will be called on the previous one.
|
|
|
Since 0.4
void champlain_view_set_size (ChamplainView *view, guint width, guint height);
|
|
|
|
|
void champlain_view_set_decel_rate (ChamplainView *view, gdouble rate);
The deceleration rate for the kinetic mode.
|
a ChamplainView |
|
a gdouble between 0.0 and 2.0 |
Since 0.4
void champlain_view_set_scroll_mode (ChamplainView *view, ChamplainScrollMode mode);
Determines the way the view reacts to scroll events.
|
a ChamplainView |
|
a ChamplainScrollMode value |
Since 0.4
void champlain_view_set_keep_center_on_resize (ChamplainView *view, gboolean value);
Keep the current centered position when resizing the view.
|
a ChamplainView |
|
a gboolean |
Since 0.4
void champlain_view_set_show_license (ChamplainView *view, gboolean value);
Show the license on the map view. The license information should always be available in a way or another in your application. You can have it in About, or on the map.
|
a ChamplainView |
|
a gboolean |
Since 0.4
void champlain_view_set_zoom_on_double_click (ChamplainView *view, gboolean value);
Should the view zoom in and recenter when the user double click on the map.
|
a ChamplainView |
|
a gboolean |
Since 0.4
void champlain_view_add_layer (ChamplainView *champlainView, ChamplainLayer *layer);
Adds a new layer to the view
|
|
|
a ChamplainLayer |
Since 0.2
gboolean champlain_view_get_coords_from_event (ChamplainView *view, ClutterEvent *event, gdouble *lat, gdouble *lon);
|
a ChamplainView |
|
a ClutterEvent |
|
|
|
|
Returns : |
the latitude, longitude coordinates for the given ClutterEvent. |
Since 0.2.8
gboolean champlain_view_get_coords_at (ChamplainView *view, guint x, guint y, gdouble *lat, gdouble *lon);
|
a ChamplainView |
|
the x position in the view |
|
the y position in the view |
|
|
|
|
Returns : |
the latitude, longitude coordinates for the given x, y position in the view. Use if you get coordinates from GtkEvents for example. |
Since 0.4
"decel-rate"
property"decel-rate" gdouble : Read / Write
The deceleration rate for the kinetic mode. The default value is 1.1.
Allowed values: [0,2]
Default value: 1.1
Since 0.2
"keep-center-on-resize"
property"keep-center-on-resize" gboolean : Read / Write
Keep the current centered position when resizing the view.
Default value: TRUE
Since 0.2.7
"latitude"
property"latitude" gdouble : Read / Write
The latitude coordonate of the map
Allowed values: [-90,90]
Default value: 0
Since 0.1
"longitude"
property"longitude" gdouble : Read / Write
The longitude coordonate of the map
Allowed values: [-180,180]
Default value: 0
Since 0.1
"map-source"
property"map-source" ChamplainMapSource* : Read / Write
The ChamplainMapSource being displayed
Since 0.2
"max-zoom-level"
property"max-zoom-level" gint : Read / Write
The highest allowed level of zoom of the content.
Allowed values: [0,20]
Default value: 20
Since 0.4
"min-zoom-level"
property"min-zoom-level" gint : Read / Write
The lowest allowed level of zoom of the content.
Allowed values: [0,20]
Default value: 0
Since 0.4
"scroll-mode"
property"scroll-mode" ChamplainScrollMode : Read / Write
Determines the way the view reacts to scroll events.
Default value: CHAMPLAIN_SCROLL_MODE_KINETIC
Since 0.4
"show-license"
property"show-license" gboolean : Read / Write
Show the license on the map view. The license information should always be available in a way or another in your application. You can have it in About, or on the map.
Default value: TRUE
Since 0.2.8
"state"
property"state" ChamplainState : Read
The view's global state. Useful to inform using if the view is busy loading tiles or not.
Default value: CHAMPLAIN_STATE_INIT
Since 0.4
"zoom-level"
property"zoom-level" gint : Read / Write
The level of zoom of the content.
Allowed values: [0,20]
Default value: 3
Since 0.1
"zoom-on-double-click"
property"zoom-on-double-click" gboolean : Read / Write
Should the view zoom in and recenter when the user double click on the map.
Default value: TRUE
Since 0.4
"animation-completed"
signalvoid user_function (ChamplainView *view, gpointer user_data) : Run Last / Has Details
The ::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".
|
the ChamplainView that received the signal |
|
user data set when the signal handler was connected. |
Since 0.4