Some fixes and optimizations
This commit is contained in:
parent
2f4e14ca1f
commit
b30c29a5f1
@ -386,19 +386,33 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
mapEventHandler = (event) => {
|
mapEventHandler = (event) => {
|
||||||
//return;
|
// select only when having observers
|
||||||
//if(event.type === 'click' && !this.onFeatureSelected.observers.length) return;
|
if(event.type === 'click' && !this.onFeatureSelected.observers.length) return;
|
||||||
//if(event.type === 'pointermode' && !this.onFeatureHover.observers.length) return;
|
if(event.type === 'pointermove' && !this.onFeatureHover.observers.length) return;
|
||||||
if(this.itemLayer && this.itemLayer.layer) {
|
if(this.itemLayer && this.itemLayer.layer) {
|
||||||
this.selectedFeatures = {};
|
this.selectedFeatures = {};
|
||||||
|
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) => {
|
this.itemLayer.layer.getFeatures(event.pixel).then((features) => {
|
||||||
if(!features.length) return;
|
if(!features.length) {
|
||||||
|
this.onFeatureHover.emit(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
let fid = features[0].getId();
|
let fid = features[0].getId();
|
||||||
|
if(event.type === 'pointermove') {
|
||||||
this.selectedFeatures[fid] = features[0];
|
this.selectedFeatures[fid] = features[0];
|
||||||
|
this.onFeatureHover.emit(features[0]);
|
||||||
|
} else {
|
||||||
|
this.onFeatureSelected.emit(features[0]);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if(this.selectionLayer) this.selectionLayer.changed();
|
if(this.selectionLayer) this.selectionLayer.changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (this.instance && this.initialized) {
|
if (this.instance && this.initialized) {
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<aol-layer-vector>
|
<aol-layer-vector>
|
||||||
<fm-map-item-source-vector [styles]="state.styles" [features]="state.features" (onFeatureSelected)="handleFeatureClick($event)" (onFeatureHover)="handleFeatureHover($event)" [selectedFeature]="state.selectedFeature" [selectedItem]="state.selectedItem"></fm-map-item-source-vector>
|
<fm-map-item-source-vector [styles]="state.styles" [features]="state.features" (onFeatureSelected)="handleFeatureClick($event)" (onFeatureHover)="handleFeatureHover($event)" [selectedFeature]="state.selectedFeature" [selectedItem]="state.selectedItem"></fm-map-item-source-vector>
|
||||||
</aol-layer-vector>
|
</aol-layer-vector>
|
||||||
|
<router-outlet name="map-layers"></router-outlet>
|
||||||
<!-- <fm-map-gps-location [position]="state.position" [headingTolerance]="20" [showHeading]="true" [heading]="state.compassHeading"></fm-map-gps-location> -->
|
<!-- <fm-map-gps-location [position]="state.position" [headingTolerance]="20" [showHeading]="true" [heading]="state.compassHeading"></fm-map-gps-location> -->
|
||||||
<div class="control-container" >
|
<div class="control-container" >
|
||||||
<router-outlet name="map-controls"></router-outlet>
|
<router-outlet name="map-controls"></router-outlet>
|
||||||
|
Loading…
Reference in New Issue
Block a user