File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,11 @@ export default class Label {
14
14
}
15
15
16
16
initText ( ) {
17
- return this . parent . getName ( )
17
+ // TODO: determine why getName is missing for patterns running on routes
18
+ // without short names
19
+ return typeof this . parent . getName === 'function'
20
+ ? this . parent . getName ( )
21
+ : null
18
22
}
19
23
20
24
render ( display ) { }
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ export default class SegmentLabel extends Label {
11
11
}
12
12
13
13
render ( display ) {
14
+ const text = this . getText ( )
15
+ // Do not attempt to render label if there is no label text.
16
+ if ( ! text ) return null
14
17
const x = this . labelAnchor . x - this . containerWidth / 2
15
18
const y = this . labelAnchor . y - this . containerHeight / 2
16
19
// Draw rounded rectangle for label.
@@ -26,7 +29,7 @@ export default class SegmentLabel extends Label {
26
29
ry : this . containerHeight / 2
27
30
} )
28
31
// Offset text location by padding
29
- display . drawText ( this . getText ( ) , {
32
+ display . drawText ( text , {
30
33
x : x + this . getPadding ( ) ,
31
34
// Offset y by a couple of pixels to account for off-centeredness.
32
35
y : y + this . getPadding ( ) + 2
Original file line number Diff line number Diff line change @@ -118,6 +118,8 @@ export default class RenderedSegment {
118
118
getLabelTextArray ( ) {
119
119
var textArray = [ ]
120
120
forEach ( this . patterns , pattern => {
121
+ // TODO: Should we attempt to extract part of the long name if short name
122
+ // is missing?
121
123
var shortName = pattern . route . route_short_name
122
124
if ( textArray . indexOf ( shortName ) === - 1 ) textArray . push ( shortName )
123
125
} )
You can’t perform that action at this time.
0 commit comments