Fix feature highlighting
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma
2020-04-16 13:19:06 +02:00
parent 9fbc946c68
commit d34a2069d6
14 changed files with 101 additions and 79 deletions

View File

@@ -35,6 +35,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
@Input() selectedItem: IItem;
@Input() styles:IStyles;
@Output() onFeaturesSelected: EventEmitter<Feature> = new EventEmitter<Feature>();
@Output() onFeatureHover: EventEmitter<Feature> = new EventEmitter<Feature>();
private stylesCache:IStyles = {};
constructor(@Host() private layer: LayerVectorComponent, private itemService: ItemService, @Host() private map: MapComponent, private itemTypeService: ItemTypeService,private featureIconService$:FeatureIconService) {
@@ -77,14 +78,12 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
this.strategy = loadingstrategy.bbox;
this.format = new GeoJSON();
this._select = new Select({
style: (feature) => {
return this.getSelectedStyle(feature);
},
style:null,
hitTolerance: 10,
layers: [this.layer.instance as Layer]
});
this._hoverSelect = new Select({
style: (feature) => {
style: (feature) => {
return this.getSelectedStyle(feature);
},
hitTolerance: 10,
@@ -102,6 +101,13 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
this.onFeaturesSelected.emit(null);
}
});
this._hoverSelect.on('select', (e) => {
if (e.selected.length > 0 && e.selected[0]) {
this.onFeatureHover.emit(e.selected[0]);
} else {
this.onFeatureHover.emit(null);
}
});
this.instance = new Vector(this);
this.host.instance.setSource(this.instance);
@@ -153,7 +159,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
}
if (changes["selectedFeature"] && this.instance) {
var features = this._select.getFeatures();
var features = this._hoverSelect.getFeatures();
var feature = changes["selectedFeature"].currentValue
//this.instance.clear(false);
//this.instance.addFeatures(features.getArray());