[gnome-maps] mapView: center on user location without animating from world map



commit 30c285ec2c57536549dda2866994b402f908f835
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Apr 2 10:57:49 2013 -0400

    mapView: center on user location without animating from world map
    
    It's not really useful or pretty to do this at startup, so remove this.

 src/mapView.js |   26 ++++++++++----------------
 1 files changed, 10 insertions(+), 16 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 2c8cd72..e295a1a 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -40,7 +40,6 @@ const MapView = new Lang.Class({
         this.actor = this.widget.get_view();
 
         this._view = this.actor;
-        this._view.set_zoom_level(3);
 
         this._markerLayer = new Champlain.MarkerLayer();
         this._markerLayer.set_selection_mode(Champlain.SelectionMode.SINGLE);
@@ -64,21 +63,16 @@ const MapView = new Lang.Class({
             }));
     },
 
-    _gotoLocation: function(location, accuracy) {
+    _gotoLocation: function(location, accuracy, animate) {
         log(location.description);
 
         let zoom = Utils.getZoomLevelForAccuracy(accuracy);
-        this._view.go_to(location.latitude, location.longitude);
-        let anim_completed_id = this._view.connect("animation-completed::go-to", Lang.bind(this,
-            function() {
-                // Apparently the signal is called before animation is really complete so if we don't
-                // zoom in idle, we get a crash. Perhaps a bug in libchamplain?
-                Mainloop.idle_add(Lang.bind(this,
-                function() {
-                    this._view.set_zoom_level(zoom);
-                    this._view.disconnect(anim_completed_id);
-                }));
-            }));
+        this._view.set_zoom_level(zoom);
+
+        if (animate)
+            this._view.go_to(location.latitude, location.longitude);
+        else
+            this._view.center_on(location.latitude, location.longitude);
     },
 
     _gotoUserLocation: function () {
@@ -95,7 +89,7 @@ const MapView = new Lang.Class({
             //        from an enum to a double in geocode-glib so lets do it after that happens.
             let accuracy = Geocode.LocationAccuracy.CITY;
 
-            this._gotoLocation(location, accuracy);
+            this._gotoLocation(location, accuracy, false);
         }
 
         let ipclient = new Geocode.Ipclient();
@@ -105,7 +99,7 @@ const MapView = new Lang.Class({
                 try {
                     let [location, accuracy] = ipclient.search_finish(res);
 
-                    this._gotoLocation(location, accuracy);
+                    this._gotoLocation(location, accuracy, true);
 
                     let variant = GLib.Variant.new('ad', [location.latitude, location.longitude]);
                     Application.settings.set_value('last-location', variant);
@@ -133,7 +127,7 @@ const MapView = new Lang.Class({
 
         if (locations.length == 1)
             // FIXME: accuracy should come from geocode-glib
-            this._gotoLocation(locations[0], Geocode.LocationAccuracy.CITY);
+            this._gotoLocation(locations[0], Geocode.LocationAccuracy.CITY, true);
         else {
             let min_latitude = 90;
             let max_latitude = -90;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]