Skip to content

Commit

Permalink
[maps] fix fit to bounds for ES document layers with joins (#73985) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese authored Aug 1, 2020
1 parent e9c01e9 commit 13a4221
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class VectorLayer extends AbstractLayer {

async getBounds({ startLoading, stopLoading, registerCancelCallback, dataFilters }) {
const isStaticLayer = !this.getSource().isBoundsAware();
if (isStaticLayer) {
if (isStaticLayer || this.hasJoins()) {
return getFeatureCollectionBounds(this._getSourceFeatureCollection(), this.hasJoins());
}

Expand Down
24 changes: 22 additions & 2 deletions x-pack/test/functional/apps/maps/auto_fit_to_bounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,30 @@ export default function ({ getPageObjects }) {
await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "ios"');
await PageObjects.maps.waitForMapPanAndZoom(origView);

const { lat, lon, zoom } = await PageObjects.maps.getView();
const { lat, lon } = await PageObjects.maps.getView();
expect(Math.round(lat)).to.equal(43);
expect(Math.round(lon)).to.equal(-102);
expect(Math.round(zoom)).to.equal(5);
});
});

describe('with joins', () => {
before(async () => {
await PageObjects.maps.loadSavedMap('join example');
await PageObjects.maps.enableAutoFitToBounds();
});

it('should automatically fit to bounds when query is applied', async () => {
// Set view to other side of world so no matching results
await PageObjects.maps.setView(0, 0, 6);

// Setting query should trigger fit to bounds and move map
const origView = await PageObjects.maps.getView();
await PageObjects.maps.setAndSubmitQuery('prop1 >= 11');
await PageObjects.maps.waitForMapPanAndZoom(origView);

const { lat, lon } = await PageObjects.maps.getView();
expect(Math.round(lat)).to.equal(0);
expect(Math.round(lon)).to.equal(60);
});
});
});
Expand Down

0 comments on commit 13a4221

Please sign in to comment.