Some fixes and optimizations
This commit is contained in:
@@ -386,17 +386,31 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
||||
}
|
||||
|
||||
mapEventHandler = (event) => {
|
||||
//return;
|
||||
//if(event.type === 'click' && !this.onFeatureSelected.observers.length) return;
|
||||
//if(event.type === 'pointermode' && !this.onFeatureHover.observers.length) return;
|
||||
// select only when having observers
|
||||
if(event.type === 'click' && !this.onFeatureSelected.observers.length) return;
|
||||
if(event.type === 'pointermove' && !this.onFeatureHover.observers.length) return;
|
||||
if(this.itemLayer && this.itemLayer.layer) {
|
||||
this.selectedFeatures = {};
|
||||
this.itemLayer.layer.getFeatures(event.pixel).then((features) => {
|
||||
if(!features.length) return;
|
||||
let fid = features[0].getId();
|
||||
this.selectedFeatures[fid] = features[0];
|
||||
})
|
||||
if(this.selectionLayer) this.selectionLayer.changed();
|
||||
if(this.itemLayer.layer ) {
|
||||
let minZoom = this.itemLayer.layer.getMinZoom();
|
||||
let currentZoom = this.map.instance.getView().getZoom();
|
||||
if(currentZoom>minZoom) {
|
||||
this.itemLayer.layer.getFeatures(event.pixel).then((features) => {
|
||||
if(!features.length) {
|
||||
this.onFeatureHover.emit(null);
|
||||
return;
|
||||
}
|
||||
let fid = features[0].getId();
|
||||
if(event.type === 'pointermove') {
|
||||
this.selectedFeatures[fid] = features[0];
|
||||
this.onFeatureHover.emit(features[0]);
|
||||
} else {
|
||||
this.onFeatureSelected.emit(features[0]);
|
||||
}
|
||||
})
|
||||
if(this.selectionLayer) this.selectionLayer.changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user