@@ -154,6 +154,12 @@ export class BaseIconSymbology extends BaseObjectSymbology {
154154 * @type {string }
155155 */
156156 get icon ( ) {
157+ // Check if _icon exists and is a string
158+ if ( ! this . _icon || typeof this . _icon !== 'string' ) {
159+ return base64png + base64pngNullData ;
160+ }
161+
162+ // Otherwise, it's base64 data that needs the prefix
157163 return base64png + this . _icon ;
158164 }
159165}
@@ -179,7 +185,6 @@ export class LayerIconSymbology extends BaseIconSymbology {
179185 * @param {string } node.title - the node title
180186 */
181187 constructor ( node ) {
182-
183188 if ( ! node . hasOwnProperty ( 'type' ) || node . type != 'layer' ) {
184189 throw new ValidationError ( 'The layer icon symbology is only available for layer type!' ) ;
185190 }
@@ -531,7 +536,11 @@ export class BaseSymbolsSymbology extends BaseObjectSymbology {
531536 */
532537 this . _icons = [ ] ;
533538 for ( const symbol of this . _symbols ) {
534- this . _icons . push ( new iconClass ( symbol ) ) ;
539+ if ( symbol ?. type === 'image' ) {
540+ this . _icons . push ( new SymbolImageSymbology ( symbol ) ) ;
541+ } else {
542+ this . _icons . push ( new iconClass ( symbol ) ) ;
543+ }
535544 }
536545
537546 /**
@@ -580,7 +589,7 @@ export class BaseSymbolsSymbology extends BaseObjectSymbology {
580589
581590 /**
582591 * The children icons
583- * @type {BaseIconSymbology[] }
592+ * @type {Array< BaseIconSymbology|SymbolImageSymbology> }
584593 */
585594 get children ( ) {
586595 return [ ...this . _icons ] ;
@@ -589,7 +598,7 @@ export class BaseSymbolsSymbology extends BaseObjectSymbology {
589598 /**
590599 * Iterate through children icons
591600 * @generator
592- * @yields {BaseIconSymbology} The next child icon
601+ * @yields {BaseIconSymbology|SymbolImageSymbology } The next child icon
593602 */
594603 * getChildren ( ) {
595604 for ( const icon of this . _icons ) {
@@ -664,7 +673,7 @@ export class LayerSymbolsSymbology extends BaseSymbolsSymbology {
664673
665674 /**
666675 * The private children icons
667- * @type {SymbolIconSymbology[]| SymbolRuleSymbology[] }
676+ * @type {Array< SymbolIconSymbology|SymbolImageSymbology>|Array< SymbolRuleSymbology|SymbolImageSymbology> }
668677 * @private
669678 */
670679 this . _icons ;
@@ -697,14 +706,22 @@ export class LayerSymbolsSymbology extends BaseSymbolsSymbology {
697706 * @type {boolean }
698707 */
699708 get legendOn ( ) {
709+ let imageCount = 0 ;
700710 for ( const symbol of this . _icons ) {
711+ if ( symbol . type === 'image' ) {
712+ imageCount += 1 ;
713+ continue ;
714+ }
701715 if ( symbol . ruleKey === '' ) {
702716 return true ;
703717 }
704718 if ( symbol . legendOn ) {
705719 return true ;
706720 }
707721 }
722+ if ( this . _icons . length === imageCount ) {
723+ return true ;
724+ }
708725 return false ;
709726 }
710727
@@ -721,7 +738,7 @@ export class LayerSymbolsSymbology extends BaseSymbolsSymbology {
721738
722739 /**
723740 * The children icons
724- * @type {Array<SymbolIconSymbology|SymbolRuleSymbology> }
741+ * @type {Array<SymbolIconSymbology|SymbolRuleSymbology|SymbolImageSymbology > }
725742 */
726743 get children ( ) {
727744 if ( this . _root !== null ) {
@@ -733,7 +750,7 @@ export class LayerSymbolsSymbology extends BaseSymbolsSymbology {
733750 /**
734751 * Iterate through children icons
735752 * @generator
736- * @yields {SymbolIconSymbology|SymbolRuleSymbology} The next child icon
753+ * @yields {SymbolIconSymbology|SymbolRuleSymbology|SymbolImageSymbology } The next child icon
737754 */
738755 * getChildren ( ) {
739756 for ( const child of this . children ) {
@@ -751,7 +768,13 @@ export class LayerSymbolsSymbology extends BaseSymbolsSymbology {
751768 }
752769 let keyChecked = [ ] ;
753770 let keyUnchecked = [ ] ;
771+ let imageCount = 0 ;
754772 for ( const symbol of this . _icons ) {
773+ if ( symbol . type === 'image' ) {
774+ imageCount += 1 ;
775+ continue ;
776+ }
777+ // If the ruleKey is empty, we don't want to add it to the parameters
755778 if ( symbol . ruleKey === '' ) {
756779 keyChecked = [ ] ;
757780 keyUnchecked = [ ] ;
@@ -764,7 +787,7 @@ export class LayerSymbolsSymbology extends BaseSymbolsSymbology {
764787 }
765788 }
766789 if ( ( keyChecked . length != 0 || keyUnchecked . length != 0 )
767- && keyChecked . length != this . _icons . length ) {
790+ && keyChecked . length !== this . _icons . length - imageCount ) {
768791 params [ 'LEGEND_ON' ] = wmsName + ':' + keyChecked . join ( ) ;
769792 params [ 'LEGEND_OFF' ] = wmsName + ':' + keyUnchecked . join ( ) ;
770793 }
0 commit comments