@@ -41,41 +41,37 @@ export function getLegendItems(context: FacilMapContext): LegendType[] {
4141 const items : LegendItem [ ] = [ ] ;
4242 const fields : Record < string , string [ ] > = Object . create ( null ) ;
4343
44- if (
45- type . colourFixed ||
46- ( type . type == "marker" && type . iconFixed && type . defaultIcon && ( iconList . includes ( type . defaultIcon ) || type . defaultIcon . length == 1 ) ) ||
47- ( type . type == "marker" && type . shapeFixed ) ||
48- ( type . type == "line" && type . widthFixed ) ||
49- ( type . type === "line" && type . strokeFixed )
50- ) {
51- const item : LegendItem = {
52- key : `legend-item-${ type . id } ` ,
53- value : type . name ,
54- label : formatTypeName ( type . name ) ,
55- filtered : true
56- } ;
57-
58- if ( type . colourFixed ) {
59- item . colour = type . defaultColour ? `#${ type . defaultColour } ` : undefined ;
60- }
61- if ( type . type == "marker" && type . iconFixed && type . defaultIcon && ( iconList . includes ( type . defaultIcon ) || type . defaultIcon . length == 1 ) ) {
62- item . icon = type . defaultIcon ;
63- }
64- if ( type . type == "marker" && type . shapeFixed ) {
65- item . shape = type . defaultShape ?? "" ;
66- }
67- if ( type . type == "line" && type . widthFixed ) {
68- item . width = type . defaultWidth ?? undefined ;
69- }
70- if ( type . type === "line" && type . strokeFixed ) {
71- item . stroke = type . defaultStroke ;
44+ const mainItem : LegendItem = {
45+ key : `legend-item-${ type . id } ` ,
46+ value : type . name ,
47+ label : formatTypeName ( type . name ) ,
48+ filtered : true
49+ } ;
50+
51+ if ( type . colourFixed ) {
52+ mainItem . colour = type . defaultColour ? `#${ type . defaultColour } ` : undefined ;
53+ }
54+ if ( type . type == "marker" && type . iconFixed && type . defaultIcon && ( iconList . includes ( type . defaultIcon ) || type . defaultIcon . length == 1 ) ) {
55+ mainItem . icon = type . defaultIcon ;
56+ }
57+ if ( type . type == "marker" ) {
58+ if ( type . shapeFixed ) {
59+ mainItem . shape = type . defaultShape ?? "" ;
60+ } else {
61+ mainItem . shape = "drop" ;
7262 }
63+ }
64+ if ( type . type == "line" && type . widthFixed ) {
65+ mainItem . width = type . defaultWidth ?? undefined ;
66+ }
67+ if ( type . type === "line" && type . strokeFixed ) {
68+ mainItem . stroke = type . defaultStroke ;
69+ }
7370
74- if ( item . colour )
75- item . bright = isBright ( item . colour ) ;
71+ if ( mainItem . colour )
72+ mainItem . bright = isBright ( mainItem . colour ) ;
7673
77- items . push ( item ) ;
78- }
74+ items . push ( mainItem ) ;
7975
8076 for ( const field of type . fields ) {
8177 if (
@@ -147,20 +143,6 @@ export function getLegendItems(context: FacilMapContext): LegendType[] {
147143 } ) ;
148144 }
149145
150- if ( items . length == 0 ) {
151- const item : LegendItem = {
152- key : `legend-item-${ type . id } ` ,
153- value : type . name ,
154- label : formatTypeName ( type . name ) ,
155- filtered : true
156- } ;
157-
158- if ( type . type == "marker" )
159- item . shape = "drop" ;
160-
161- items . push ( item ) ;
162- }
163-
164146 const legendType : LegendType = {
165147 key : `legend-type-${ type . id } ` ,
166148 type : type . type ,
0 commit comments