[gnome-maps] mapView: Go to/center on location before zooming-in



commit 6b335034a1609c064e4c0188c6554b56505a8c6f
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sat Apr 6 04:44:59 2013 +0300

    mapView: Go to/center on location before zooming-in
    
    When taking the view to a location, zoom in after the view is there.
    While this may not be important when not animating, it looks much better
    to zoom-in only on the location of interest.

 src/mapView.js |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index a131ef6..a8f23cf 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -81,12 +81,25 @@ const MapView = new Lang.Class({
         log(location.description);
 
         let zoom = Utils.getZoomLevelForAccuracy(location.accuracy);
-        this._view.set_zoom_level(zoom);
 
-        if (animate)
-            this._view.go_to(location.latitude, location.longitude);
-        else
+        if (!animate) {
             this._view.center_on(location.latitude, location.longitude);
+            this._view.set_zoom_level(zoom);
+
+            return;
+        }
+
+        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.go_to(location.latitude, location.longitude);
     },
 
     _gotoUserLocation: function () {


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