Fix feature highlighting
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -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());
|
||||
|
Reference in New Issue
Block a user