[gnome-maps] Move/zoom-in/zoom-out to show search results



commit 56e05b63dc225f141a70b6ca4b87a7b6f187ef59
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Mar 25 19:06:15 2013 +0200

    Move/zoom-in/zoom-out to show search results
    
    After a successful search for places, adjust the view to show all search
    results on the map to user.
    
    Code to find the bounding box borrowed from emerillon.

 src/mainToolbar.js |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 1fc0649..88a4157 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -70,6 +70,11 @@ const MainToolbar = new Lang.Class({
         if (locations.length == 0)
             return;
 
+        let min_latitude = 90;
+        let max_latitude = -90;
+        let min_longitude = 180;
+        let max_longitude = -180;
+
         locations.forEach(Lang.bind(this,
             function(location) {
                 log ("location: " + location);
@@ -78,6 +83,23 @@ const MainToolbar = new Lang.Class({
                 marker.set_location(location.latitude, location.longitude);
                 this._markerLayer.add_marker(marker);
                 log ("Added marker at " + location.latitude + ", " + location.longitude);
+
+                if (location.latitude > max_latitude)
+                    max_latitude = location.latitude;
+                if (location.latitude < min_latitude)
+                    min_latitude = location.latitude;
+                if (location.longitude > max_longitude)
+                    max_longitude = location.longitude;
+                if (location.longitude < min_longitude)
+                    min_longitude = location.longitude;
             }));
+
+        let bbox = new Champlain.BoundingBox();
+        bbox.left = min_longitude;
+        bbox.right = max_longitude;
+        bbox.bottom = min_latitude;
+        bbox.top = max_latitude;
+
+        this._mainWindow.view.ensure_visible (bbox, true);
     }
 });


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