Skip to content

Commit fbdcdf7

Browse files
nreesekibanamachine
andcommitted
[Maps] fix zooming while drawing shape filter logs errors in console (#88413)
* [Maps] fix zooming while drawing shape filter logs errors in console * add unit test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 7bdac0b commit fbdcdf7

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

x-pack/plugins/maps/public/connected_components/mb_map/mb.utils.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,16 @@ describe('removeOrphanedSourcesAndLayers', () => {
185185
removeOrphanedSourcesAndLayers(mockMbMap, [], spatialFilterLayer);
186186
expect(mockMbMap.getStyle()).toEqual(styleWithSpatialFilters);
187187
});
188+
189+
test('should not remove mapbox gl draw layers and sources', async () => {
190+
const fooLayer = makeMultiSourceMockLayer('foo');
191+
const layerList = [fooLayer];
192+
193+
const currentStyle = getMockStyle(layerList);
194+
currentStyle.layers.push({ id: 'gl-draw-points' });
195+
const mockMbMap = new MockMbMap(currentStyle);
196+
197+
removeOrphanedSourcesAndLayers(mockMbMap, layerList, spatialFilterLayer);
198+
expect(mockMbMap.getStyle()).toEqual(currentStyle);
199+
});
188200
});

x-pack/plugins/maps/public/connected_components/mb_map/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export function removeOrphanedSourcesAndLayers(mbMap, layerList, spatialFilterLa
1616
return;
1717
}
1818

19+
// ignore gl-draw layers
20+
if (mbLayer.id.startsWith('gl-draw')) {
21+
return;
22+
}
23+
1924
const layer = layerList.find((layer) => {
2025
return layer.ownsMbLayerId(mbLayer.id);
2126
});

0 commit comments

Comments
 (0)