[gnome-maps/wip/routing: 2/3] MapView: add support for showing routes



commit d8a6a1118e6c978292c22ad4ee556489ebcc172c
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Fri Aug 30 03:02:30 2013 +0200

    MapView: add support for showing routes
    
    WIP! Add:
      * clearing of routes

 src/mapView.js |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 2269cfc..459568d 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -76,6 +76,10 @@ const MapView = new Lang.Class({
         this._userLocationLayer.set_selection_mode(Champlain.SelectionMode.SINGLE);
         this.view.add_layer(this._userLocationLayer);
 
+        this._routeLayer = new Champlain.PathLayer();
+        this._routeLayer.set_stroke_width(2.0);
+        this.view.add_layer(this._routeLayer);
+
         this._factory = Champlain.MapSourceFactory.dup_default();
         this.setMapType(MapType.STREET);
 
@@ -155,6 +159,13 @@ const MapView = new Lang.Class({
         mapLocation.goTo(true);
     },
 
+    showRoute: function(route) {
+        route.coordinates.forEach(function(coordinate) {
+            this._routeLayer.add_node(coordinate);
+        }, this);
+        this.view.ensure_visible(route.bbox, true);
+    },
+
     _onViewMoved: function() {
         this.emit('view-moved');
     }


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