Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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