-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Maps] layer groups * createLayerGroup * create layer group * setChildren * display layer group legend * display nested layers in TOC * setLayerVisibility * set parent on layer re-order * LayerGroup.getBounds * clean-up LayerGroup * edit layer panel * LayerGroup.cloneDescriptor * clean up * remove layer * fix reorder bug * move children on layer move * fix re-order bug when dragging layer group with collapsed details * add check for dragging to same location * add logic to prevent dragging layer group into its own family tree * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * add layer to layer group combine action with layer group * clean up * fix bug where unable to move layer to bottom * mouse cursor styles * clean up combine styling * fix jest tests * update toc_entry_actions_popover snapshots * click confirm model on removeLayer in functional tests * update cloneLayer to move clones beneath parent * LayerGroup.getErrors * Update x-pack/plugins/maps/common/descriptor_types/layer_descriptor_types.ts Co-authored-by: Nick Peihl <nickpeihl@gmail.com> * fix show this layer only action when layer is nested * recursive count children for remove layer warning * Update x-pack/plugins/maps/public/components/remove_layer_confirm_modal.tsx Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com> * resolve error with show this layer only on layer group * update remove statement to support plural * perserve layer order when cloning layer group Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Nick Peihl <nickpeihl@gmail.com> Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com>
- Loading branch information
1 parent
97eb9b6
commit e45170e
Showing
37 changed files
with
2,063 additions
and
974 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import bbox from '@turf/bbox'; | ||
import { multiPoint } from '@turf/helpers'; | ||
import { MapExtent } from '../../common/descriptor_types'; | ||
import { turfBboxToBounds } from '../../common/elasticsearch_util'; | ||
import { ILayer } from '../classes/layers/layer'; | ||
import type { DataRequestContext } from './data_request_actions'; | ||
import { DataRequestAbortError } from '../classes/util/data_request'; | ||
|
||
export async function getLayersExtent( | ||
layers: ILayer[], | ||
getDataRequestContext: (layerId: string) => DataRequestContext | ||
): Promise<MapExtent | null> { | ||
if (!layers.length) { | ||
return null; | ||
} | ||
|
||
const boundsPromises = layers.map(async (layer: ILayer) => { | ||
if (!(await layer.isFittable())) { | ||
return null; | ||
} | ||
return layer.getBounds(getDataRequestContext); | ||
}); | ||
|
||
let bounds; | ||
try { | ||
bounds = await Promise.all(boundsPromises); | ||
} catch (error) { | ||
if (!(error instanceof DataRequestAbortError)) { | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
'Unhandled getBounds error for layer. Only DataRequestAbortError should be surfaced', | ||
error | ||
); | ||
} | ||
// new fitToDataBounds request has superseded this thread of execution. Results no longer needed. | ||
return null; | ||
} | ||
|
||
const corners = []; | ||
for (let i = 0; i < bounds.length; i++) { | ||
const b = bounds[i]; | ||
|
||
// filter out undefined bounds (uses Infinity due to turf responses) | ||
if ( | ||
b === null || | ||
b.minLon === Infinity || | ||
b.maxLon === Infinity || | ||
b.minLat === -Infinity || | ||
b.maxLat === -Infinity | ||
) { | ||
continue; | ||
} | ||
|
||
corners.push([b.minLon, b.minLat]); | ||
corners.push([b.maxLon, b.maxLat]); | ||
} | ||
|
||
return corners.length ? turfBboxToBounds(bbox(multiPoint(corners))) : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.