ChamplainMapSource map_source;
gint zoom_level; // only used when the zoom-level property is set before map is created
- gdouble longitude; // only used when the center_on is called before map is created
- gdouble latitude; // only used when the center_on is called before map is created
+
+ // Represents the (lat, lon) at the center of the viewport
+ gdouble longitude;
+ gdouble latitude;
ClutterActor *map_layer;
ClutterActor *viewport;
{
case PROP_LONGITUDE:
{
- gdouble lon = g_value_get_double(value);
- gdouble lat = viewport_get_current_latitude(priv);
- champlain_view_center_on(view, lat, lon);
+ champlain_view_center_on (view, priv->latitude, g_value_get_double (value));
break;
}
case PROP_LATITUDE:
{
- gdouble lon = viewport_get_current_longitude(priv);
- gdouble lat = g_value_get_double(value);
- champlain_view_center_on(view, lat, lon);
+ champlain_view_center_on (view, g_value_get_double (value), priv->longitude);
break;
}
case PROP_ZOOM_LEVEL:
if (level != priv->map->current_level->level)
{
ClutterActor *group = priv->map->current_level->group;
- gdouble lat = viewport_get_current_latitude(priv);
- gdouble lon = viewport_get_current_longitude(priv);
if (map_zoom_to(priv->map, level))
{
resize_viewport(view);
clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), group);
clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group);
- champlain_view_center_on(view, lat, lon);
+ champlain_view_center_on(view, priv->latitude, priv->longtitude);
}
}
}
if (priv->map_source != source)
{
priv->map_source = source;
- gdouble lat = viewport_get_current_latitude(priv);
- gdouble lon = viewport_get_current_longitude(priv);
if (priv->map) {
guint currentLevel = priv->map->current_level->level;
map_free(priv->map);
clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group);
marker_reposition(view);
- champlain_view_center_on(view, lat, lon);
+ champlain_view_center_on(view, priv->latitude, priv->longitude);
}
}
break;
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
- gdouble lon = viewport_get_current_longitude(priv);
- gdouble lat = viewport_get_current_latitude(priv);
-
priv->viewport_size.width = width;
priv->viewport_size.height = height;
resize_viewport(view);
if (priv->keep_center_on_resize)
- champlain_view_center_on(view, lat, lon);
+ champlain_view_center_on(view, priv->latitude, priv->longitude);
else
map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline);
}
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
+ priv->longitude = longitude;
+ priv->latitude = latitude;
+
if(!priv->map)
- {
- // keep until the viewport is created
- priv->longitude = longitude;
- priv->latitude = latitude;
- return;
- }
+ return;
gdouble x, y;
x = priv->map->longitude_to_x(priv->map, longitude, priv->map->current_level->level);
g_object_notify(G_OBJECT(view), "latitude");
map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline);
- marker_reposition(view);
+ marker_reposition (view);
}
/**
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
ClutterActor *group = priv->map->current_level->group;
- gdouble lon = viewport_get_current_longitude(priv);
- gdouble lat = viewport_get_current_latitude(priv);
if(map_zoom_in(priv->map))
{
resize_viewport(view);
clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), group);
clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group);
- champlain_view_center_on(view, lat, lon);
+ champlain_view_center_on(view, priv->latitude, priv->longitude);
g_object_notify(G_OBJECT(view), "zoom-level");
}
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
ClutterActor *group = priv->map->current_level->group;
- gdouble lon = viewport_get_current_longitude(priv);
- gdouble lat = viewport_get_current_latitude(priv);
if(map_zoom_out(priv->map))
{
resize_viewport(view);
clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), group);
clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group);
- champlain_view_center_on(view, lat, lon);
+ champlain_view_center_on(view, priv->latitude, priv->longitude);
g_object_notify(G_OBJECT(view), "zoom-level");
}
static gboolean
montreal_click (ClutterActor *actor,
ClutterEvent *event,
- gpointer user_data)
-{ g_print("Montreal was clicked!\n");
- return TRUE;
+ ChamplainView *view)
+{
+ g_print("Montreal was clicked!\n");
+ champlain_view_center_on(CHAMPLAIN_VIEW(view), 45.466, -73.75);
+ return TRUE;
}
static ClutterActor*
-create_marker_layer ()
+create_marker_layer (ChamplainView *view)
{
ClutterActor *layer, *marker;
g_signal_connect_after (marker,
"button-release-event",
G_CALLBACK (montreal_click),
- NULL);
+ view);
marker = champlain_marker_new_with_label("New York", "Sans 25", &white, NULL);
champlain_marker_set_position(CHAMPLAIN_MARKER(marker), 40.77, -73.98);
champlain_view_set_size (CHAMPLAIN_VIEW (actor), 800, 600);
g_object_set(G_OBJECT(actor), "zoom-level", 5, NULL);
- layer = create_marker_layer();
+ layer = create_marker_layer(actor);
champlain_view_add_layer(CHAMPLAIN_VIEW (actor), layer);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);