Skip to content

Commit

Permalink
fit only on visible features (#42020)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Jul 26, 2019
1 parent 3229834 commit ec82c13
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions x-pack/legacy/plugins/maps/public/layers/vector_layer.js
Expand Up @@ -196,7 +196,12 @@ export class VectorLayer extends AbstractLayer {
if (!featureCollection) {
return null;
}
const bbox = turf.bbox(featureCollection);

const visibleFeatures = featureCollection.features.filter(feature => feature.properties[FEATURE_VISIBLE_PROPERTY_NAME]);
const bbox = turf.bbox({
type: 'FeatureCollection',
features: visibleFeatures
});
return {
min_lon: bbox[0],
min_lat: bbox[1],
Expand All @@ -206,11 +211,14 @@ export class VectorLayer extends AbstractLayer {
}

async getBounds(dataFilters) {
if (this._source.isBoundsAware()) {
const searchFilters = this._getSearchFilters(dataFilters);
return await this._source.getBoundsForFilters(searchFilters);

const isStaticLayer = !this._source.isBoundsAware() || !this._source.isFilterByMapBounds();
if (isStaticLayer) {
return this._getBoundsBasedOnData();
}
return this._getBoundsBasedOnData();

const searchFilters = this._getSearchFilters(dataFilters);
return await this._source.getBoundsForFilters(searchFilters);
}

async getLeftJoinFields() {
Expand Down

0 comments on commit ec82c13

Please sign in to comment.