AW1873Bouwplanlabels generalize
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Peter Bastiani 2023-08-23 15:17:38 +02:00
parent 45537cb2e9
commit 1d0f3b958d

View File

@ -41,9 +41,8 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
@Output() onFeatureSelected: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>(); @Output() onFeatureSelected: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
@Output() onFeatureHover: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>(); @Output() onFeatureHover: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
private stylesCache: IStyles = {}; private stylesCache: IStyles = {};
private labelToolSettings = { showFieldName: true, showCropName: true, showArea: false, showCentroid: false };
private sub: Subscription; 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) { 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); super(layer);
@ -86,13 +85,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
userSettingsRoot => { userSettingsRoot => {
this.itemService.getChildItemList(userSettingsRoot.code, 'vnd.farmmaps.itemtype.settings.general').subscribe( this.itemService.getChildItemList(userSettingsRoot.code, 'vnd.farmmaps.itemtype.settings.general').subscribe(
items => { items => {
if (items && items.length > 0) { this.displayMapFeatureSettings = items && items.length > 0 ? items[0].data?.displayMapFeatureSettings : null;
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');
}
} }
) )
}); });
@ -154,7 +147,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
color: fillColor color: fillColor
}), }),
geometry: (feature: Feature<Geometry>) => this.geometry(feature), geometry: (feature: Feature<Geometry>) => this.geometry(feature),
text: this.getDisplayTextForFeature(feature, this.propertiesToShow) text: this.getDisplayTextForFeature(feature)
}); });
} else { } else {
key = 'file'; key = 'file';
@ -214,9 +207,9 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
} }
} }
getDisplayTextForFeature(feature: Feature<Geometry>, propertiesToShow: string[], overrule: style.Text = null, zoom: { min: number, current: number } = null): style.Text { getDisplayTextForFeature(feature: Feature<Geometry>, overrule: style.Text = null, zoom: { min: number, current: number } = null): style.Text {
if (!feature) return null; 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) return null;
if (propertiesToShow.length <= 0) return null; if (propertiesToShow.length <= 0) return null;
if (zoom && zoom.current > zoom.min) return null; if (zoom && zoom.current > zoom.min) return null;