[gnome-maps/wip/mlundblad/transit-routing: 21/26] turnPointMarker: Add support for showing markers for transit stops



commit 358fe8d1942324c34ba93aac3925a3cb9bc60ec8
Author: Marcus Lundblad <ml update uu se>
Date:   Fri Jul 15 23:46:57 2016 +0200

    turnPointMarker: Add support for showing markers for transit stops
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755808

 src/turnPointMarker.js |   41 +++++++++++++++++++++++++++++++----------
 1 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index 9bc9036..7e893c2 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -41,12 +41,26 @@ const TurnPointMarker = new Lang.Class({
         this._turnPoint = params.turnPoint;
         delete params.turnPoint;
 
+        this._transitStop = params.transitStop;
+        delete params.transitStop;
+
+        this._transitLeg = params.transitLeg;
+        delete params.transitLeg;
+
+        let latitude;
+        let longitude;
+
+        if (this._turnPoint) {
+            latitude = this._turnPoint.coordinate.get_latitude();
+            longitude = this._turnPoint.coordinate.get_longitude();
+        } else {
+            latitude = this._transitStop.coordinate[0];
+            longitude = this._transitStop.coordinate[1];
+        }
+
         params.place = new Place.Place({
-            location: new Location.Location({
-                latitude: this._turnPoint.coordinate.get_latitude(),
-                longitude: this._turnPoint.coordinate.get_longitude()
-            })
-        });
+            location: new Location.Location({ latitude: latitude,
+                                              longitude: longitude }) });
         this.parent(params);
 
         let actor;
@@ -57,11 +71,7 @@ const TurnPointMarker = new Lang.Class({
             }).bind(this));
             actor = this._actorFromIconName(this._turnPoint.iconName, 0);
         } else {
-            // A GNOMEish blue color
-            let color = new Gdk.RGBA({ red: 33   / 255,
-                                       green: 93 / 255,
-                                       blue: 156 / 255,
-                                       alpha: 255 });
+            let color = this._getColor();
             actor = this._actorFromIconName('maps-point-end-symbolic',
                                             0,
                                             color);
@@ -69,6 +79,17 @@ const TurnPointMarker = new Lang.Class({
         this.add_actor(actor);
     },
 
+    _getColor: function() {
+        /* use a GNOMEish blue color for turn-by-turn routing, and the transit-
+         * defined leg color (when available) for transit routes */
+        let color = this._turnPoint ? '215D9C' : this._transitLeg.color;
+        let red = parseInt(color.substring(0, 2), 16) / 255;
+        let green = parseInt(color.substring(2, 4), 16) / 255;
+        let blue = parseInt(color.substring(4, 6), 16) / 255;
+
+        return new Gdk.RGBA({ red: red, green: green, blue: blue, alpha: 255 });
+    },
+
     get anchor() {
         return { x: Math.floor(this.width / 2) - 1,
                  y: Math.floor(this.height / 2) - 1 };


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