[gnome-maps/wip/mlundblad/transit-routing: 8/9] turnPointMarker: Add support for showing markers for transit stops
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-routing: 8/9] turnPointMarker: Add support for showing markers for transit stops
- Date: Fri, 15 Jul 2016 21:52:48 +0000 (UTC)
commit a5b2e4da673913010c6637403a7ab144a58466ac
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
src/turnPointMarker.js | 51 ++++++++++++++++++++++++++++++++++++++---------
1 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index 9bc9036..dfd9539 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -30,6 +30,8 @@ const MapMarker = imports.mapMarker;
const Place = imports.place;
const Utils = imports.utils;
+const DEFAULT_TRANSIT_COLOR = '000000';
+
const TurnPointMarker = new Lang.Class({
Name: 'TurnPointMarker',
Extends: MapMarker.MapMarker,
@@ -41,12 +43,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 +73,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 +81,25 @@ const TurnPointMarker = new Lang.Class({
this.add_actor(actor);
},
+ _getColor: function() {
+ if (this._turnPoint) {
+ /* A GNOMEish blue color */
+ return new Gdk.RGBA({ red: 33 / 255,
+ green: 93 / 255,
+ blue: 156 / 255,
+ alpha: 255 });
+ } else {
+ /* get color from transit leg, if available */
+ let color = this._transitLeg.color ?
+ this._transitLeg.color : DEFAULT_TRANSIT_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]