How to get features from cluster source for current extent? I need to collect all features from cluster for current extent and zoom state.
I tried this:
this.mapService.map.getView().on('change:resolution', (evt) => {
const a = (this.clusterVector.getSource() as VectorSource).getFeaturesByExtent(this.clusterVector.getSource().getExtent());
console.log(a);
});
It does not work for me correctly, it returns more features when user zoom in instead less.
I have made some research and now there is:
this.mapService.map.getView().on('change:resolution', (evt) => {
const extent = this.mapService.map
.getView()
.calculateExtent(this.mapService.map.getSize());
const features =
this.clusterSource.getFeaturesInExtent(extent);
Is it proper way?