[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>
This commit is contained in:
Nathan Reese 2021-01-15 19:05:45 -07:00 committed by GitHub
parent fbb8238f57
commit c66c9424d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -185,4 +185,16 @@ describe('removeOrphanedSourcesAndLayers', () => {
removeOrphanedSourcesAndLayers(mockMbMap, [], spatialFilterLayer);
expect(mockMbMap.getStyle()).toEqual(styleWithSpatialFilters);
});
test('should not remove mapbox gl draw layers and sources', async () => {
const fooLayer = makeMultiSourceMockLayer('foo');
const layerList = [fooLayer];
const currentStyle = getMockStyle(layerList);
currentStyle.layers.push({ id: 'gl-draw-points' });
const mockMbMap = new MockMbMap(currentStyle);
removeOrphanedSourcesAndLayers(mockMbMap, layerList, spatialFilterLayer);
expect(mockMbMap.getStyle()).toEqual(currentStyle);
});
});

View file

@ -16,6 +16,11 @@ export function removeOrphanedSourcesAndLayers(mbMap, layerList, spatialFilterLa
return;
}
// ignore gl-draw layers
if (mbLayer.id.startsWith('gl-draw')) {
return;
}
const layer = layerList.find((layer) => {
return layer.ownsMbLayerId(mbLayer.id);
});