From: Pierre-Luc Beaudoin Date: Sat, 6 Sep 2008 20:21:49 +0000 (-0400) Subject: Move initial map creation to a function X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e29fdad40228f43bc03759d385c382ab041d0a01;p=libchamplain Move initial map creation to a function In case the functions aren't called in the same order than planned. --- diff --git a/champlain/champlainview.c b/champlain/champlainview.c index baa8d9d..857b034 100644 --- a/champlain/champlainview.c +++ b/champlain/champlainview.c @@ -130,6 +130,20 @@ marker_reposition (ChamplainView *view) clutter_container_foreach(CLUTTER_CONTAINER(priv->user_layers), CLUTTER_CALLBACK(layer_reposition_cb), view); } +static void +create_initial_map(ChamplainView *view) +{ + ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + priv->map = map_new(priv->map_source); + map_load_level(priv->map, priv->zoom_level); + clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); + + marker_reposition(view); + + g_object_notify(G_OBJECT(view), "zoom-level"); + g_object_notify(G_OBJECT(view), "map-source"); +} + static void resize_viewport(ChamplainView *view) { @@ -140,14 +154,7 @@ resize_viewport(ChamplainView *view) if(!priv->map) { - priv->map = map_new(priv->map_source); - map_load_level(priv->map, priv->zoom_level); - clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); - - marker_reposition(view); - - g_object_notify(G_OBJECT(view), "zoom-level"); - g_object_notify(G_OBJECT(view), "map-source"); + create_initial_map(view); } clutter_actor_set_size (priv->finger_scroll, priv->viewport_size.width, priv->viewport_size.height); @@ -561,6 +568,11 @@ champlain_view_center_on (ChamplainView *view, gdouble longitude, gdouble latitu { ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + if(!priv->map) + { + create_initial_map(view); + } + gdouble x, y; x = priv->map->longitude_to_x(priv->map, longitude, priv->map->current_level->level); y = priv->map->latitude_to_y(priv->map, latitude, priv->map->current_level->level);