Skip to content

Commit

Permalink
[Map] return bounding box for static feature collection without joins (
Browse files Browse the repository at this point in the history
…elastic#66607)

* [Map] return bounding box for static feature collection without joins

* tslint

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
# Conflicts:
#	x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.js
  • Loading branch information
nreese committed May 15, 2020
1 parent 6eb7f30 commit ca5361f
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions x-pack/plugins/maps/public/layers/vector_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import turf from 'turf';
import React from 'react';
import { AbstractLayer } from './layer';
import { VectorStyle } from './styles/vector/vector_style';
Expand All @@ -30,6 +29,7 @@ import {
canSkipFormattersUpdate,
} from './util/can_skip_fetch';
import { assignFeatureIds } from './util/assign_feature_ids';
import { getFeatureCollectionBounds } from '../../util/get_feature_collection_bounds';
import {
getFillFilterExpression,
getLineFilterExpression,
Expand Down Expand Up @@ -153,31 +153,10 @@ export class VectorLayer extends AbstractLayer {
return this.getCurrentStyle().renderLegendDetails();
}

_getBoundsBasedOnData() {
const featureCollection = this._getSourceFeatureCollection();
if (!featureCollection) {
return null;
}

const visibleFeatures = featureCollection.features.filter(
feature => feature.properties[FEATURE_VISIBLE_PROPERTY_NAME]
);
const bbox = turf.bbox({
type: 'FeatureCollection',
features: visibleFeatures,
});
return {
minLon: bbox[0],
minLat: bbox[1],
maxLon: bbox[2],
maxLat: bbox[3],
};
}

async getBounds(dataFilters) {
const isStaticLayer = !this.getSource().isBoundsAware();
if (isStaticLayer) {
return this._getBoundsBasedOnData();
return getFeatureCollectionBounds(this._getSourceFeatureCollection(), this._hasJoins());
}

const searchFilters = this._getSearchFilters(
Expand Down

0 comments on commit ca5361f

Please sign in to comment.