Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[maps] fix fit to bounds for ES document layers with joins #73985

Merged
merged 1 commit into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
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
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