Skip to content

Commit 13a4221

Browse files
authored
[maps] fix fit to bounds for ES document layers with joins (#73985) (#74040)
1 parent e9c01e9 commit 13a4221

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class VectorLayer extends AbstractLayer {
158158

159159
async getBounds({ startLoading, stopLoading, registerCancelCallback, dataFilters }) {
160160
const isStaticLayer = !this.getSource().isBoundsAware();
161-
if (isStaticLayer) {
161+
if (isStaticLayer || this.hasJoins()) {
162162
return getFeatureCollectionBounds(this._getSourceFeatureCollection(), this.hasJoins());
163163
}
164164

x-pack/test/functional/apps/maps/auto_fit_to_bounds.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,30 @@ export default function ({ getPageObjects }) {
2525
await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "ios"');
2626
await PageObjects.maps.waitForMapPanAndZoom(origView);
2727

28-
const { lat, lon, zoom } = await PageObjects.maps.getView();
28+
const { lat, lon } = await PageObjects.maps.getView();
2929
expect(Math.round(lat)).to.equal(43);
3030
expect(Math.round(lon)).to.equal(-102);
31-
expect(Math.round(zoom)).to.equal(5);
31+
});
32+
});
33+
34+
describe('with joins', () => {
35+
before(async () => {
36+
await PageObjects.maps.loadSavedMap('join example');
37+
await PageObjects.maps.enableAutoFitToBounds();
38+
});
39+
40+
it('should automatically fit to bounds when query is applied', async () => {
41+
// Set view to other side of world so no matching results
42+
await PageObjects.maps.setView(0, 0, 6);
43+
44+
// Setting query should trigger fit to bounds and move map
45+
const origView = await PageObjects.maps.getView();
46+
await PageObjects.maps.setAndSubmitQuery('prop1 >= 11');
47+
await PageObjects.maps.waitForMapPanAndZoom(origView);
48+
49+
const { lat, lon } = await PageObjects.maps.getView();
50+
expect(Math.round(lat)).to.equal(0);
51+
expect(Math.round(lon)).to.equal(60);
3252
});
3353
});
3454
});

0 commit comments

Comments
 (0)