[gnome-maps/wip/jonasdn/storedRoute: 5/13] mapView: Add method to show stored route



commit 25ba742aa0793f38d6d9b75c0f31bc40dfd459e8
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Thu Feb 12 20:42:34 2015 +0100

    mapView: Add method to show stored route
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744425

 src/mapView.js |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index c9586b8..b535304 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -33,6 +33,7 @@ const Geoclue = imports.geoclue;
 const MapWalker = imports.mapWalker;
 const Place = imports.place;
 const PlaceMarker = imports.placeMarker;
+const StoredRoute = imports.storedRoute;
 const TurnPointMarker = imports.turnPointMarker;
 const UserLocationMarker = imports.userLocationMarker;
 const Utils = imports.utils;
@@ -234,16 +235,44 @@ const MapView = new Lang.Class({
         this._gotoBBox(contact.bounding_box);
     },
 
+    _showStoredRoute: function(stored) {
+        let query = Application.routeService.query;
+        let route = Application.routeService.route;
+
+        Application.routeService.storedRoute = stored.route;
+
+        let resetId = route.connect('reset', function() {
+            route.disconnect(resetId);
+            query.freeze_notify();
+
+            let storedLast = stored.places.length - 1;
+            query.points[0].place = stored.places[0];
+            query.points[1].place = stored.places[storedLast];
+
+            for (let i = 1; i < storedLast; i++) {
+                let point = query.addPoint(i);
+                point.place = stored.places[i];
+            }
+
+            query.thaw_notify();
+        });
+        route.reset();
+    },
+
     showSearchResult: function(place) {
         this._placeLayer.remove_all();
+
+        if (place instanceof StoredRoute.StoredRoute) {
+            this._showStoredRoute(place);
+            return;
+        }
+
         this.routeVisible = false;
         let placeMarker = new PlaceMarker.PlaceMarker({ place: place,
                                                         mapView: this });
 
         this._placeLayer.add_marker(placeMarker);
         placeMarker.goToAndSelect(true);
-
-        return placeMarker;
     },
 
     showRoute: function(route) {


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