From 6c22e968c55bc4aa12ef2a079f52f505d615d554 Mon Sep 17 00:00:00 2001 From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com> Date: Wed, 8 May 2024 13:33:38 -0400 Subject: [PATCH 1/2] adding method to clear out the bullseye map layers on the removal of all observation selections. --- .../trays/observations/removeObservations.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/trays/observations/removeObservations.js b/src/components/trays/observations/removeObservations.js index 76f2aa96..20beaa7a 100644 --- a/src/components/trays/observations/removeObservations.js +++ b/src/components/trays/observations/removeObservations.js @@ -2,6 +2,8 @@ import React, { Fragment } from 'react'; import { Button } from '@mui/joy'; import {useLayers} from "@context"; +// import { markUnclicked } from '@utils/map-utils'; + /** * component that handles the removal of all observation selections from the map. @@ -12,13 +14,25 @@ import {useLayers} from "@context"; export const RemoveObservations = () => { // get references to the observation data/list const { + map, selectedObservations, setSelectedObservations } = useLayers(); - // remove the observation selections from state + /** + * remove the observation selections from state and map + */ function removeAllObservations() { - // remove all items from the data list + // remove all the targets on the map + map.eachLayer((layer) => { + // if this is an observation selection marker + if (layer.options && layer.options.pane === "markerPane") { + // remove the layer + map.removeLayer(layer); + } + }); + + // remove all the dialog items from the data list setSelectedObservations(selectedObservations.filter(item => item === undefined)); } From d8a61dcc6a901c03a7c0df8f301a52086666c4a2 Mon Sep 17 00:00:00 2001 From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com> Date: Wed, 8 May 2024 13:37:13 -0400 Subject: [PATCH 2/2] tidying up --- src/components/trays/observations/removeObservations.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/trays/observations/removeObservations.js b/src/components/trays/observations/removeObservations.js index 20beaa7a..6751f0ac 100644 --- a/src/components/trays/observations/removeObservations.js +++ b/src/components/trays/observations/removeObservations.js @@ -2,8 +2,6 @@ import React, { Fragment } from 'react'; import { Button } from '@mui/joy'; import {useLayers} from "@context"; -// import { markUnclicked } from '@utils/map-utils'; - /** * component that handles the removal of all observation selections from the map.