@@ -46,42 +46,38 @@ export function getLegendItems(context: FacilMapContext): LegendType[] {
4646 const items : LegendItem [ ] = [ ] ;
4747 const fields : Record < string , string [ ] > = Object . create ( null ) ;
4848
49- if (
50- type . colourFixed ||
51- ( type . type == "marker" && type . iconFixed && type . defaultIcon && ( iconList . includes ( type . defaultIcon ) || type . defaultIcon . length == 1 ) ) ||
52- ( type . type == "marker" && type . shapeFixed ) ||
53- ( type . type == "line" && type . widthFixed ) ||
54- ( type . type === "line" && type . strokeFixed )
55- ) {
56- const item : LegendItem = {
57- key : `legend-item-${ type . id } ` ,
58- fieldId : undefined ,
59- value : type . name ,
60- label : formatTypeName ( type . name ) ,
61- filtered : true
62- } ;
63-
64- if ( type . colourFixed ) {
65- item . colour = type . defaultColour ? `#${ type . defaultColour } ` : undefined ;
66- }
67- if ( type . type == "marker" && type . iconFixed && type . defaultIcon && ( iconList . includes ( type . defaultIcon ) || type . defaultIcon . length == 1 ) ) {
68- item . icon = type . defaultIcon ;
69- }
70- if ( type . type == "marker" && type . shapeFixed ) {
71- item . shape = type . defaultShape ?? "" ;
72- }
73- if ( type . type == "line" && type . widthFixed ) {
74- item . width = type . defaultWidth ?? undefined ;
75- }
76- if ( type . type === "line" && type . strokeFixed ) {
77- item . stroke = type . defaultStroke ;
49+ const mainItem : LegendItem = {
50+ key : `legend-item-${ type . id } ` ,
51+ fieldId : undefined ,
52+ value : type . name ,
53+ label : formatTypeName ( type . name ) ,
54+ filtered : true
55+ } ;
56+
57+ if ( type . colourFixed ) {
58+ mainItem . colour = type . defaultColour ? `#${ type . defaultColour } ` : undefined ;
59+ }
60+ if ( type . type == "marker" && type . iconFixed && type . defaultIcon && ( iconList . includes ( type . defaultIcon ) || type . defaultIcon . length == 1 ) ) {
61+ mainItem . icon = type . defaultIcon ;
62+ }
63+ if ( type . type == "marker" ) {
64+ if ( type . shapeFixed ) {
65+ mainItem . shape = type . defaultShape ?? "" ;
66+ } else {
67+ mainItem . shape = "drop" ;
7868 }
69+ }
70+ if ( type . type == "line" && type . widthFixed ) {
71+ mainItem . width = type . defaultWidth ?? undefined ;
72+ }
73+ if ( type . type === "line" && type . strokeFixed ) {
74+ mainItem . stroke = type . defaultStroke ;
75+ }
7976
80- if ( item . colour )
81- item . bright = isBright ( item . colour ) ;
77+ if ( mainItem . colour )
78+ mainItem . bright = isBright ( mainItem . colour ) ;
8279
83- items . push ( item ) ;
84- }
80+ items . push ( mainItem ) ;
8581
8682 for ( const field of type . fields ) {
8783 if (
@@ -154,21 +150,6 @@ export function getLegendItems(context: FacilMapContext): LegendType[] {
154150 } ) ;
155151 }
156152
157- if ( items . length == 0 ) {
158- const item : LegendItem = {
159- key : `legend-item-${ type . id } ` ,
160- fieldId : undefined ,
161- value : type . name ,
162- label : formatTypeName ( type . name ) ,
163- filtered : true
164- } ;
165-
166- if ( type . type == "marker" )
167- item . shape = "drop" ;
168-
169- items . push ( item ) ;
170- }
171-
172153 const legendType : LegendType = {
173154 key : `legend-type-${ type . id } ` ,
174155 type : type . type ,
0 commit comments