Skip to content

Commit

Permalink
[Maps] handle case where fit to bounds does not match any documents (#…
Browse files Browse the repository at this point in the history
…66307)

* [Maps] handle case where fit to bounds does not match any documents

* review feedback
  • Loading branch information
nreese authored May 13, 2020
1 parent 9b01e6b commit 9e0504e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/maps/public/actions/map_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ export function fitToDataBounds() {
const b = bounds[i];

//filter out undefined bounds (uses Infinity due to turf responses)

if (
b === null ||
b.minLon === Infinity ||
b.maxLon === Infinity ||
b.minLat === -Infinity ||
Expand Down
17 changes: 6 additions & 11 deletions x-pack/plugins/maps/public/classes/sources/es_source/es_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,13 @@ export class AbstractESSource extends AbstractVectorSource {
let esBounds;
try {
const esResp = await searchSource.fetch();
esBounds = _.get(esResp, 'aggregations.fitToBounds.bounds');
if (!esResp.aggregations.fitToBounds.bounds) {
// aggregations.fitToBounds is empty object when there are no matching documents
return null;
}
esBounds = esResp.aggregations.fitToBounds.bounds;
} catch (error) {
esBounds = {
top_left: {
lat: 90,
lon: -180,
},
bottom_right: {
lat: -90,
lon: 180,
},
};
return null;
}

const minLon = esBounds.top_left.lon;
Expand Down

0 comments on commit 9e0504e

Please sign in to comment.