diff --git a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts b/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts index 85accfa..eac320b 100644 --- a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts +++ b/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts @@ -41,9 +41,8 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements @Output() onFeatureSelected: EventEmitter> = new EventEmitter>(); @Output() onFeatureHover: EventEmitter> = new EventEmitter>(); private stylesCache: IStyles = {}; - private labelToolSettings = { showFieldName: true, showCropName: true, showArea: false, showCentroid: false }; private sub: Subscription; - private propertiesToShow: string[] = []; + private displayMapFeatureSettings: { [code: string]: string[] }; constructor(@Host() private layer: LayerVectorComponent, private itemService: ItemService, private map: MapComponent, private itemTypeService: ItemTypeService, private featureIconService$: FeatureIconService, private folderService: FolderService, @Inject(LOCALE_ID) private locale: string) { super(layer); @@ -86,13 +85,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements userSettingsRoot => { this.itemService.getChildItemList(userSettingsRoot.code, 'vnd.farmmaps.itemtype.settings.general').subscribe( items => { - if (items && items.length > 0) { - this.propertiesToShow = []; - if (items[0].data.labelToolSettings.showFieldName) this.propertiesToShow.push('name'); - if (items[0].data.labelToolSettings.showCropName) this.propertiesToShow.push('cropTypeName'); - if (items[0].data.labelToolSettings.showArea) this.propertiesToShow.push('area'); - if (items[0].data.labelToolSettings.showCentroid) this.propertiesToShow.push('centroid'); - } + this.displayMapFeatureSettings = items && items.length > 0 ? items[0].data?.displayMapFeatureSettings : null; } ) }); @@ -154,7 +147,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements color: fillColor }), geometry: (feature: Feature) => this.geometry(feature), - text: this.getDisplayTextForFeature(feature, this.propertiesToShow) + text: this.getDisplayTextForFeature(feature) }); } else { key = 'file'; @@ -214,9 +207,9 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements } } - getDisplayTextForFeature(feature: Feature, propertiesToShow: string[], overrule: style.Text = null, zoom: { min: number, current: number } = null): style.Text { + getDisplayTextForFeature(feature: Feature, overrule: style.Text = null, zoom: { min: number, current: number } = null): style.Text { if (!feature) return null; - if (feature.get('itemType') !== 'vnd.farmmaps.itemtype.cropfield') return null; + const propertiesToShow: string[] = this.displayMapFeatureSettings[feature.get('itemType')]; if (!propertiesToShow) return null; if (propertiesToShow.length <= 0) return null; if (zoom && zoom.current > zoom.min) return null;