[gnome-maps/wip/mlundblad/transit-routing: 8/8] mapView: WIP, implement showing transit routes



commit b354e8fa5093ec6a4cee21bdefddfc93bde5d56d
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Mar 29 23:10:22 2016 +0200

    mapView: WIP, implement showing transit routes

 src/mapView.js |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index e8db3bb..fb07b0c 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -189,6 +189,7 @@ const MapView = new Lang.Class({
 
     _connectRouteSignals: function() {
         let route = Application.routeService.route;
+        let transitPlan = Application.openTripPlanner.plan;
         let query = Application.routeQuery;
 
         route.connect('update', this.showRoute.bind(this, route));
@@ -196,6 +197,11 @@ const MapView = new Lang.Class({
             this._routeLayer.remove_all();
             this._instructionMarkerLayer.remove_all();
         }).bind(this));
+        transitPlan.connect('update', this.showTransitPlan.bind(this, transitPlan));
+        transitPlan.connect('reset', (function() {
+            this._routeLayer.remove_all();
+            this._instructionMarkerLayer.remove_all();
+        }).bind(this));
 
         query.connect('notify', (function() {
                 this.routeVisible = query.isValid();
@@ -481,6 +487,23 @@ const MapView = new Lang.Class({
         }, this);
     },
 
+    showTransitPlan: function(plan) {
+        this._routeLayer.remove_all();
+        this._placeLayer.remove_all();
+        this._instructionMarkerLayer.remove_all();
+
+        this.routeVisible = true;
+        Utils.debug('showing transit plan…');
+
+        /* TODO: for now always show the first itinerary */
+        let itinerary = plan.itineraries[0];
+        itinerary.legs.forEach((function(leg) {
+            leg.polyline.forEach(this._routeLayer.add_node.bind(this._routeLayer));
+        }).bind(this));
+
+        this.gotoBBox(plan.bbox);
+    },
+
     _onViewMoved: function() {
         this.emit('view-moved');
         if (this._storeId !== 0)


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