]> err.no Git - libchamplain/commitdiff
Move initial map creation to a function
authorPierre-Luc Beaudoin <pierre-luc@squidy.info>
Sat, 6 Sep 2008 20:21:49 +0000 (16:21 -0400)
committerPierre-Luc Beaudoin <pierre-luc@squidy.info>
Sat, 6 Sep 2008 20:21:49 +0000 (16:21 -0400)
In case the functions aren't called in the same order than planned.

champlain/champlainview.c

index baa8d9dfa0b7464c7d4573ba3b6408a44b868192..857b034affe8cae140839c3092590ea1bf489316 100644 (file)
@@ -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);