[gnome-maps] mapLocation: use place bbox for ensuring visible



commit 1def9bc0769fb27ade4efe4488e9a3af6f8098ff
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Wed Jan 29 13:54:32 2014 +0100

    mapLocation: use place bbox for ensuring visible
    
    Use the bounding box of the GeocodePlace in the ensure
    visible operation. This will make sure that we reach a
    zoom-level that includes the whole of the new place we
    are travelling to.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722865

 src/mapLocation.js |   24 +++++++++++++++++++++++-
 src/mapView.js     |    2 +-
 2 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/mapLocation.js b/src/mapLocation.js
index 1ce82fb..3c56086 100644
--- a/src/mapLocation.js
+++ b/src/mapLocation.js
@@ -41,6 +41,17 @@ const MapLocation = new Lang.Class({
     Name: 'MapLocation',
 
     _init: function(place, mapView) {
+        if (place.bounding_box !== null) {
+            this.bbox = new Champlain.BoundingBox({
+                top: place.bounding_box.top,
+                bottom: place.bounding_box.bottom,
+                left: place.bounding_box.left,
+                right: place.bounding_box.right
+            });
+        } else {
+            this.bbox = null;
+        }
+
         this._mapView = mapView;
         this._view = mapView.view;
         this.latitude = place.location.latitude;
@@ -91,7 +102,7 @@ const MapLocation = new Lang.Class({
             this._view.go_to(this.latitude, this.longitude);
         }).bind(this));
 
-        this._mapView.ensureVisible([fromLocation, this]);
+        this._ensureVisible(fromLocation);
     },
 
     show: function(layer) {
@@ -154,6 +165,17 @@ const MapLocation = new Lang.Class({
         }
     },
 
+    _ensureVisible: function(fromLocation) {
+        if (this.bbox !== null) {
+            let visibleBox = this.bbox.copy();
+
+            visibleBox.extend(fromLocation.latitude, fromLocation.longitude);
+            this._view.ensure_visible(visibleBox, true);
+        } else {
+            this._mapView.ensureLocationsVisible([fromLocation, this]);
+        }
+    },
+
     _updateGoToDuration: function(fromLocation) {
         let toLocation = new Geocode.Location({
             latitude: this.latitude,
diff --git a/src/mapView.js b/src/mapView.js
index 8c32d1e..00d4a3e 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -129,7 +129,7 @@ const MapView = new Lang.Class({
         }).bind(this));
     },
 
-    ensureVisible: function(locations) {
+    ensureLocationsVisible: function(locations) {
         let bbox = new Champlain.BoundingBox({ left:   180,
                                                right: -180,
                                                bottom:  90,


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