From ea1952e2369fb7229b1cbd388d56ed6e9a307eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Mon, 14 Sep 2020 13:27:08 -0400 Subject: [PATCH] fix(legend): fix stylesAvailable undefined --- .../lib/layer/layer-legend/layer-legend.component.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/geo/src/lib/layer/layer-legend/layer-legend.component.ts b/packages/geo/src/lib/layer/layer-legend/layer-legend.component.ts index 1090d69c48..4bc20d20f6 100644 --- a/packages/geo/src/lib/layer/layer-legend/layer-legend.component.ts +++ b/packages/geo/src/lib/layer/layer-legend/layer-legend.component.ts @@ -165,10 +165,12 @@ export class LayerLegendComponent implements OnInit, OnDestroy { if (layerOptions && layerOptions.legendOptions) { const translate = this.languageService.translate; const title = translate.instant('igo.geo.layer.legend.default'); - const stylesAvailable = [{ name: '', title } as ItemStyleOptions] - .concat(layerOptions.legendOptions.stylesAvailable.filter(sA => ( - sA.name.normalize('NFD').replace(/[\u0300-\u036f]/gi, '') !== 'default' && - sA.name.normalize('NFD').replace(/[\u0300-\u036f]/gi, '') !== 'defaut'))); + let stylesAvailable = [{ name: '', title } as ItemStyleOptions]; + if (layerOptions.legendOptions.stylesAvailable) { + stylesAvailable.concat(layerOptions.legendOptions.stylesAvailable.filter(sA => ( + sA.name.normalize('NFD').replace(/[\u0300-\u036f]/gi, '') !== 'default' && + sA.name.normalize('NFD').replace(/[\u0300-\u036f]/gi, '') !== 'defaut'))); + } stylesAvailable.map(s => s.title = s.title.charAt(0).toUpperCase() + s.title.slice(1).replace(/_/g, ' ')); return stylesAvailable; }