![]() |
![]() |
![]() |
libchamplain Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
ChamplainViewChamplainView — A ClutterActor to display maps |
struct 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 *view
); void champlain_view_zoom_out (ChamplainView *view
); void champlain_view_set_zoom_level (ChamplainView *view
,guint zoom_level
); void champlain_view_set_min_zoom_level (ChamplainView *view
,guint zoom_level
); void champlain_view_set_max_zoom_level (ChamplainView *view
,guint zoom_level
); void champlain_view_ensure_visible (ChamplainView *view
,ChamplainBoundingBox *bbox
,gboolean animate
); void champlain_view_ensure_layers_visible (ChamplainView *view
,gboolean animate
); void champlain_view_set_map_source (ChamplainView *view
,ChamplainMapSource *map_source
); void champlain_view_set_deceleration (ChamplainView *view
,gdouble rate
); void champlain_view_set_kinetic_mode (ChamplainView *view
,gboolean kinetic
); void champlain_view_set_keep_center_on_resize (ChamplainView *view
,gboolean value
); void champlain_view_set_zoom_on_double_click (ChamplainView *view
,gboolean value
); void champlain_view_set_animate_zoom (ChamplainView *view
,gboolean value
); void champlain_view_set_background_pattern (ChamplainView *view
,ClutterContent *background
); void champlain_view_add_layer (ChamplainView *view
,ChamplainLayer *layer
); void champlain_view_remove_layer (ChamplainView *view
,ChamplainLayer *layer
); guint champlain_view_get_zoom_level (ChamplainView *view
); guint champlain_view_get_min_zoom_level (ChamplainView *view
); guint champlain_view_get_max_zoom_level (ChamplainView *view
); ChamplainMapSource * champlain_view_get_map_source (ChamplainView *view
); gdouble champlain_view_get_deceleration (ChamplainView *view
); gboolean champlain_view_get_kinetic_mode (ChamplainView *view
); gboolean champlain_view_get_keep_center_on_resize (ChamplainView *view
); gboolean champlain_view_get_zoom_on_double_click (ChamplainView *view
); gboolean champlain_view_get_animate_zoom (ChamplainView *view
); ClutterContent * champlain_view_get_background_pattern (ChamplainView *view
); void champlain_view_reload_tiles (ChamplainView *view
); gdouble champlain_view_x_to_longitude (ChamplainView *view
,gdouble x
); gdouble champlain_view_y_to_latitude (ChamplainView *view
,gdouble y
); gdouble champlain_view_longitude_to_x (ChamplainView *view
,gdouble longitude
); gdouble champlain_view_latitude_to_y (ChamplainView *view
,gdouble latitude
); void champlain_view_get_viewport_origin (ChamplainView *view
,gint *x
,gint *y
); void champlain_view_bin_layout_add (ChamplainView *view
,ClutterActor *child
,ClutterBinAlignment x_align
,ClutterBinAlignment y_align
); ChamplainLicense * champlain_view_get_license_actor (ChamplainView *view
); gdouble champlain_view_get_center_latitude (ChamplainView *view
); gdouble champlain_view_get_center_longitude (ChamplainView *view
); ChamplainBoundingBox * champlain_view_get_bounding_box (ChamplainView *view
); ChamplainState champlain_view_get_state (ChamplainView *view
);
ChamplainView implements ClutterContainer, ClutterScriptable, ClutterAnimatable and AtkImplementorIface.
"animate-zoom" gboolean : Read / Write "background-pattern" ClutterActor* : Read / Write "deceleration" gdouble : Read / Write "keep-center-on-resize" gboolean : Read / Write "kinetic-mode" gboolean : Read / Write "latitude" gdouble : Read / Write "longitude" gdouble : Read / Write "map-source" ChamplainMapSource* : Read / Write "max-zoom-level" guint : Read / Write "min-zoom-level" guint : Read / Write "state" ChamplainState : Read "zoom-level" guint : 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 don'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 and released on the view
.
struct ChamplainView;
The ChamplainView structure contains only private data and should be accessed using the provided API
Since 0.1
ClutterActor * champlain_view_new (void
);
Creates an instance of ChamplainView.
Returns : |
a new ChamplainView ready to be used as a ClutterActor. |
Since 0.4
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 *view
);
Zoom in the map by one level.
|
a ChamplainView |
Since 0.1
void champlain_view_zoom_out (ChamplainView *view
);
Zoom out the map by one level.
|
a ChamplainView |
Since 0.1
void champlain_view_set_zoom_level (ChamplainView *view
,guint zoom_level
);
Changes the current level of zoom
|
a ChamplainView |
|
the level of zoom, a guint between 1 and 20 |
Since 0.4
void champlain_view_set_min_zoom_level (ChamplainView *view
,guint zoom_level
);
Changes the lowest allowed level of zoom
|
a ChamplainView |
|
the level of zoom |
Since 0.4
void champlain_view_set_max_zoom_level (ChamplainView *view
,guint zoom_level
);
Changes the highest allowed level of zoom
|
a ChamplainView |
|
the level of zoom |
Since 0.4
void champlain_view_ensure_visible (ChamplainView *view
,ChamplainBoundingBox *bbox
,gboolean animate
);
Changes the map's zoom level and center to make sure the given area is visible
|
a ChamplainView |
|
bounding box of the area that should be visible |
|
TRUE to perform animation, FALSE otherwise |
Since 0.10
void champlain_view_ensure_layers_visible (ChamplainView *view
,gboolean animate
);
Changes the map's zoom level and center to make sure that the bounding boxes of all inserted layers are visible.
|
a ChamplainView |
|
TRUE to perform animation, FALSE otherwise |
Since 0.10
void champlain_view_set_map_source (ChamplainView *view
,ChamplainMapSource *map_source
);
Changes the currently used map source. #g_object_unref()
will be called on
the previous one.
|
a ChamplainView |
|
a ChamplainMapSource |
Since 0.4
void champlain_view_set_deceleration (ChamplainView *view
,gdouble rate
);
The deceleration rate for the kinetic mode.
|
a ChamplainView |
|
a gdouble between 1.001 and 2.0 |
Since 0.4
void champlain_view_set_kinetic_mode (ChamplainView *view
,gboolean kinetic
);
Determines the way the view reacts to scroll events.
|
a ChamplainView |
|
TRUE for kinetic mode, FALSE for push mode |
Since 0.10
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_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_set_animate_zoom (ChamplainView *view
,gboolean value
);
Should the view animate zoom level changes.
|
a ChamplainView |
|
a gboolean |
Since 0.12
void champlain_view_set_background_pattern (ChamplainView *view
,ClutterContent *background
);
Sets the background texture displayed behind the map. Setting the background pattern affects performence slightly - use reasonably large patterns for better performance.
|
a ChamplainView |
|
The background texture |
Since 0.12.4
void champlain_view_add_layer (ChamplainView *view
,ChamplainLayer *layer
);
Adds a new layer to the view
|
a ChamplainView |
|
a ChamplainLayer |
Since 0.2
void champlain_view_remove_layer (ChamplainView *view
,ChamplainLayer *layer
);
Removes the given layer from the view
|
a ChamplainView |
|
a ChamplainLayer |
Since 0.4.1
guint champlain_view_get_zoom_level (ChamplainView *view
);
Gets the view's current zoom level.
|
a ChamplainView |
Returns : |
the view's current zoom level. |
Since 0.4
guint champlain_view_get_min_zoom_level (ChamplainView *view
);
Gets the view's minimal allowed zoom level.
|
a ChamplainView |
Returns : |
the view's minimal allowed zoom level. |
Since 0.4
guint champlain_view_get_max_zoom_level (ChamplainView *view
);
Gets the view's maximum allowed zoom level.
|
a ChamplainView |
Returns : |
the view's maximum allowed zoom level. |
Since 0.4
ChamplainMapSource * champlain_view_get_map_source (ChamplainView *view
);
Gets the view's current map source.
|
a ChamplainView |
Returns : |
the view's current map source. If you need to keep a reference to the
map source then you have to call #g_object_ref() . [transfer none]
|
Since 0.4
gdouble champlain_view_get_deceleration (ChamplainView *view
);
Gets the view's deceleration rate.
|
a ChamplainView |
Returns : |
the view's deceleration rate. |
Since 0.4
gboolean champlain_view_get_kinetic_mode (ChamplainView *view
);
Gets the view's scroll mode behaviour.
|
a ChamplainView |
Returns : |
TRUE for kinetic mode, FALSE for push mode. |
Since 0.10
gboolean champlain_view_get_keep_center_on_resize
(ChamplainView *view
);
Checks whether to keep the center on resize
|
a ChamplainView |
Returns : |
TRUE if the view keeps the center on resize, FALSE otherwise. |
Since 0.4
gboolean champlain_view_get_zoom_on_double_click
(ChamplainView *view
);
Checks whether the view zooms on double click.
|
a ChamplainView |
Returns : |
TRUE if the view zooms on double click, FALSE otherwise. |
Since 0.4
gboolean champlain_view_get_animate_zoom (ChamplainView *view
);
Checks whether the view animates zoom level changes.
|
a ChamplainView |
Returns : |
TRUE if the view animates zooms, FALSE otherwise. |
Since 0.12
ClutterContent * champlain_view_get_background_pattern
(ChamplainView *view
);
Gets the current background texture displayed behind the map.
|
a ChamplainView |
Returns : |
The texture. [transfer none] |
Since 0.12.4
void champlain_view_reload_tiles (ChamplainView *view
);
Reloads all visible tiles.
|
a ChamplainView |
Since 0.8
gdouble champlain_view_x_to_longitude (ChamplainView *view
,gdouble x
);
Converts the view's x coordinate to longitude.
|
a ChamplainView |
|
x coordinate of the view |
Returns : |
the longitude |
Since 0.10
gdouble champlain_view_y_to_latitude (ChamplainView *view
,gdouble y
);
Converts the view's y coordinate to latitude.
|
a ChamplainView |
|
y coordinate of the view |
Returns : |
the latitude |
Since 0.10
gdouble champlain_view_longitude_to_x (ChamplainView *view
,gdouble longitude
);
Converts the longitude to view's x coordinate.
|
a ChamplainView |
|
the longitude |
Returns : |
the x coordinate |
Since 0.10
gdouble champlain_view_latitude_to_y (ChamplainView *view
,gdouble latitude
);
Converts the latitude to view's y coordinate.
|
a ChamplainView |
|
the latitude |
Returns : |
the y coordinate |
Since 0.10
void champlain_view_get_viewport_origin (ChamplainView *view
,gint *x
,gint *y
);
Gets the x and y coordinate of the viewport in respect to the layer origin.
|
a ChamplainView |
|
the x coordinate of the viewport. [out] |
|
the y coordinate of the viewport. [out] |
Since 0.10
void champlain_view_bin_layout_add (ChamplainView *view
,ClutterActor *child
,ClutterBinAlignment x_align
,ClutterBinAlignment y_align
);
champlain_view_bin_layout_add
has been deprecated since version 0.12.4 and should not be used in newly-written code. Use ClutterActorAlign and the ClutterActor
API instead.
This function inserts a custom actor to the undrelying ClutterBinLayout
manager. The inserted actors appear on top of the map. See clutter_bin_layout_add()
for reference.
|
a ChamplainView |
|
The child to be inserted |
|
x alignment |
|
y alignment |
Since 0.10
ChamplainLicense * champlain_view_get_license_actor (ChamplainView *view
);
Returns the ChamplainLicense actor which is inserted by default into the layout manager. It can be manipulated using standard ClutterActor methods (hidden and so on).
|
a ChamplainView |
Returns : |
the license actor. [transfer none] |
Since 0.10
gdouble champlain_view_get_center_latitude (ChamplainView *view
);
Gets the latitude of the view's center.
|
a ChamplainView |
Returns : |
the latitude. |
Since 0.10
gdouble champlain_view_get_center_longitude (ChamplainView *view
);
Gets the longitude of the view's center.
|
a ChamplainView |
Returns : |
the longitude. |
Since 0.10
ChamplainBoundingBox * champlain_view_get_bounding_box (ChamplainView *view
);
Gets the bounding box for view view
at current zoom-level.
|
a ChamplainView |
Returns : |
the bounding box. [transfer full] |
Since 0.12.4
ChamplainState champlain_view_get_state (ChamplainView *view
);
Gets the view's state.
|
a ChamplainView |
Returns : |
the state. |
Since 0.10
"animate-zoom"
property"animate-zoom" gboolean : Read / Write
Animate zoom change when zooming in/out.
Default value: TRUE
Since 0.12
"background-pattern"
property"background-pattern" ClutterActor* : Read / Write
The pattern displayed in the background of the map.
Since 0.12.4
"deceleration"
property"deceleration" gdouble : Read / Write
The deceleration rate for the kinetic mode. The default value is 1.1.
Allowed values: [1.0001,2]
Default value: 1.1
Since 0.10
"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
"kinetic-mode"
property"kinetic-mode" gboolean : Read / Write
Determines whether the view should use kinetic mode.
Default value: TRUE
Since 0.10
"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" guint : Read / Write
The highest allowed level of zoom of the content.
Allowed values: <= 20
Default value: 20
Since 0.4
"min-zoom-level"
property"min-zoom-level" guint : Read / Write
The lowest allowed level of zoom of the content.
Allowed values: <= 20
Default value: 0
Since 0.4
"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_NONE
Since 0.4
"zoom-level"
property"zoom-level" guint : Read / Write
The level of zoom of the content.
Allowed values: <= 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 *arg0,
gpointer user_data) : 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".
|
user data set when the signal handler was connected. |
Since 0.4
"layer-relocated"
signalvoid user_function (ChamplainView *arg0,
gpointer user_data) : Run Last
Indicates that the layers have been "relocated". In practice this means that every layer should connect to this signal and redraw itself when the signal is emitted. Layer relocation happens when zooming in/out and when panning for more than MAX_INT pixels.
|
user data set when the signal handler was connected. |
Since 0.10