@@ -4,41 +4,54 @@ import { Theme } from 'types';
4
4
5
5
interface PlatformProps {
6
6
colors : Theme ;
7
+ fieldName ?: string ;
8
+ leftOffset ?: number ;
7
9
maxzoom ?: number ;
8
10
minzoom ?: number ;
9
- leftOffset ?: number ;
11
+ rotation ?: 'map' | 'viewport' | 'auto' ;
10
12
sourceLayer : string ;
11
13
}
12
14
13
15
/*
14
16
* signals
15
- detectors: seulement ceux sous un signal, ceux qu'on genere en sur les tiv de jonction connait pas leur pk
16
- buffer stops
17
- les panneaux des psl
18
- les operational point parts
17
+ OK detectors: seulement ceux sous un signal, ceux qu'on genere en sur les tiv de jonction connait pas leur pk
18
+ OK buffer stops
19
+ OK les panneaux des psl
20
+ OK les operational point parts
19
21
*/
20
22
21
23
export default function configKPLabelLayer ( props : PlatformProps ) {
22
- const { colors, leftOffset = - 1 , maxzoom = 24 , minzoom = 7 , sourceLayer } = props ;
24
+ const {
25
+ colors,
26
+ fieldName = 'kp' ,
27
+ leftOffset = - 1 ,
28
+ maxzoom = 24 ,
29
+ minzoom = 7 ,
30
+ rotation = 'viewport' ,
31
+ sourceLayer,
32
+ } = props ;
23
33
const rkValue : LayerProps = {
24
34
type : 'symbol' ,
25
35
'source-layer' : sourceLayer ,
26
- filter : [ '!=' , ' ', [ 'get' , 'extensions_sncf_kp' ] ] ,
36
+ filter : [ 'all' , [ ' !=', [ 'literal ', null ] , [ 'get' , fieldName ] ] , [ '!=' , '' , [ 'get' , fieldName ] ] ] ,
27
37
maxzoom,
28
38
minzoom,
29
39
layout : {
30
- 'text-field' : [ 'concat' , 'PK ' , [ 'get' , 'extensions_sncf_kp' ] ] ,
40
+ 'text-field' : [ 'concat' , 'PK ' , [ 'get' , fieldName ] ] ,
31
41
'text-font' : [ 'Roboto Medium' ] ,
32
42
'text-size' : 9 ,
33
43
'text-anchor' : 'right' ,
34
44
'text-allow-overlap' : true ,
35
45
'text-ignore-placement' : true ,
36
46
'text-offset' : [ leftOffset , 0.1 ] ,
47
+ 'text-rotation-alignment' : rotation ,
48
+ 'text-pitch-alignment' : rotation ,
49
+ 'text-rotate' : rotation === 'map' ? [ 'get' , 'angle_geo' ] : 0 ,
37
50
} ,
38
51
paint : {
39
- 'text-color' : colors . rk . text ,
52
+ 'text-color' : colors . kp . text ,
40
53
'text-halo-width' : 0 ,
41
- 'text-halo-color' : colors . rk . halo ,
54
+ 'text-halo-color' : colors . kp . halo ,
42
55
'text-halo-blur' : 1 ,
43
56
} ,
44
57
} ;
0 commit comments