diff --git a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts index 292b359..0d49d9f 100644 --- a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts +++ b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts @@ -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(); + } + } } } diff --git a/projects/common-map/src/fm-map/components/map/map.component.html b/projects/common-map/src/fm-map/components/map/map.component.html index f9895dc..4607522 100644 --- a/projects/common-map/src/fm-map/components/map/map.component.html +++ b/projects/common-map/src/fm-map/components/map/map.component.html @@ -38,6 +38,7 @@ +