@@ -30,7 +30,8 @@ function generate_tooltip_text({ inv_number, type }) {
3030
3131function create_icon ( { type, geo :{ speed} , route_ref, reduce_marker} ) {
3232 const state = speed > MIN_ACTIVE_SPEED ? 'active' : 'passive' ;
33-
33+ const bearing = vehicle . geo . bearing ;
34+
3435 const width = ! reduce_marker ?29 :29 / 3 ; // initial 25px
3536 const half_width = width / 2 ;
3637 const height = ! reduce_marker ?45 :45 ; // initial 41px
@@ -42,14 +43,12 @@ function create_icon({type, geo:{speed}, route_ref, reduce_marker}) {
4243
4344 const class_name = route_ref != null && route_ref . toString ( ) . length <= 2 ? 'large' : 'small' ;
4445
45- const open_svg = `<svg width="${ width } " height="${ height } " xmlns="http://www.w3.org/2000/svg">` ;
46- const outer_circle = `<circle stroke="black" stroke-width="0.95px" cx="${ half_width } " cy="${ half_width } " r="${ half_width } "/>` ;
46+ const open_svg = `<svg width="${ width + 1 } " height="${ height + 1 } " viewBox="-0.5 -0.5 ${ width + 0.5 } ${ height + 0.5 } " xmlns="http://www.w3.org/2000/svg">` ;
47+ const circle = `<circle stroke="black" stroke-width="0.95px" cx="${ half_width } " cy="${ half_width } " r="${ half_width } "/>` ;
4748 const triangle = `<polygon points="${ triangle_left_point } ${ triangle_right_point } ${ triangle_acute_point } "/>` ;
4849 const triangle_outline = `<g stroke="black" stroke-width="0.95px"><line x1="${ triangle_left_point . split ( ',' ) [ 0 ] } " y1="${ triangle_left_point . split ( ',' ) [ 1 ] } " x2="${ triangle_acute_point . split ( ',' ) [ 0 ] } " y2="${ triangle_acute_point . split ( ',' ) [ 1 ] } "/><line x1="${ triangle_right_point . split ( ',' ) [ 0 ] } " y1="${ triangle_right_point . split ( ',' ) [ 1 ] } " x2="${ triangle_acute_point . split ( ',' ) [ 0 ] } " y2="${ triangle_acute_point . split ( ',' ) [ 1 ] } "/></g>` ;
49- const group_open = '<g>' ;
50- const group_close = '</g>' ;
5150
52- const text = `<text x="${ half_width } px" y="${ half_width } px" dominant-baseline="middle" text-anchor="middle" class="svg_text svg_${ class_name } " transform-origin="${ half_width } ${ half_width } ">${ route_ref ? route_ref : '' } </text>` ;
51+ const text = `<text x="${ half_width } px" y="${ half_width } px" dominant-baseline="middle" text-anchor="middle" class="svg_text svg_${ class_name } " transform-origin="${ half_width } ${ half_width } " transform="rotate( ${ state == 'active' ? - bearing + 360 : 0 } )" >${ route_ref ?? '' } </text>` ;
5352 const close_svg = '</svg>' ;
5453
5554 const route_type = typeof route_ref === 'string' && route_ref . startsWith ( 'N' ) ? 'night' : type ;
@@ -60,11 +59,11 @@ function create_icon({type, geo:{speed}, route_ref, reduce_marker}) {
6059 className : `vehicle-${ route_type } `
6160 }
6261 if ( state == 'active' ) {
63- options . html = `${ open_svg } ${ outer_circle } ${ group_open } ${ triangle } ${ triangle_outline } ${ group_close } ${ text } ${ close_svg } ` ;
62+ options . html = `${ open_svg } ${ circle } ${ triangle } ${ triangle_outline } ${ text } ${ close_svg } ` ;
6463 options . rotationOrigin = options . iconAnchor . map ( a => a + ' px' ) . join ( ' ' ) ;
6564 }
6665 else {
67- options . html = `${ open_svg } ${ outer_circle } ${ text } ${ close_svg } ` ;
66+ options . html = `${ open_svg } ${ circle } ${ text } ${ close_svg } ` ;
6867 }
6968 const icon = L . divIcon ( options ) ;
7069 return icon ;
0 commit comments