diff --git a/src/components/BaselayerSections.tsx b/src/components/BaselayerSections.tsx index 85cd78a..8f5d9e3 100644 --- a/src/components/BaselayerSections.tsx +++ b/src/components/BaselayerSections.tsx @@ -19,7 +19,11 @@ export function BaselayerSections({ return ( <> {internalBaselayerMaps?.map((map, index) => ( - + {map.bands.map((band) => (
))} { - + {EXTERNAL_BASELAYERS.map((bl) => (
void; showMenu: boolean; additionalButtons?: ReactNode[]; submapData?: SubmapData; showMenuOverlay?: boolean; flipped: boolean; + mapRef: React.RefObject; }; export function BoxMenu({ @@ -25,7 +27,15 @@ export function BoxMenu({ submapData, showMenuOverlay, flipped, + mapRef, }: BoxMenuProps) { + const map = mapRef.current; + + const topLeftBoxPosition = map?.getPixelFromCoordinate([ + boxData.top_left_ra, + boxData.top_left_dec, + ]); + return (
diff --git a/src/components/layers/AddHighlightBoxLayer.tsx b/src/components/layers/AddHighlightBoxLayer.tsx index 2517062..4f5d85f 100644 --- a/src/components/layers/AddHighlightBoxLayer.tsx +++ b/src/components/layers/AddHighlightBoxLayer.tsx @@ -6,6 +6,7 @@ import { BoxMenu } from '../BoxMenu'; import VectorLayer from 'ol/layer/Vector'; import { Map } from 'ol'; import { MapProps } from '../OpenLayersMap'; +import { drawStyle } from '../../utils/layerUtils'; type AddHightlightBoxLayerProps = { mapRef: React.RefObject; @@ -56,6 +57,7 @@ export function AddHighlightBoxLayer({ type: 'Circle', geometryFunction: createBox(), geometryName: 'drawn-box-feature', + style: drawStyle, }); draw.on('drawend', (e) => { @@ -87,8 +89,6 @@ export function AddHighlightBoxLayer({ top_left_dec, bottom_right_ra, bottom_right_dec, - top: topLeftBoxPosition[1], - left: topLeftBoxPosition[0], width: boxWidth, height: boxHeight, }); @@ -142,6 +142,7 @@ export function AddHighlightBoxLayer({ <> {newBoxData && ( (null); const [selectedBoxData, setSelectedBoxData] = useState< - BoxWithPositionalData | undefined + BoxWithDimensions | undefined >(undefined); const [showMenu, setShowMenu] = useState(false); const addedLayerIdsRef = useRef>(new Set()); @@ -70,8 +70,6 @@ export function HighlightBoxLayer({ setSelectedBoxData({ ...boxData, - top: topLeft[1], - left: topLeft[0], width, height, }); @@ -274,6 +272,7 @@ export function HighlightBoxLayer({
{showMenu && selectedBoxData && ( & { - top: number; - left: number; width: number; height: number; }; diff --git a/src/utils/layerUtils.ts b/src/utils/layerUtils.ts index d5e0b0c..cf88cac 100644 --- a/src/utils/layerUtils.ts +++ b/src/utils/layerUtils.ts @@ -2,6 +2,9 @@ import { Feature } from 'ol'; import { BandWithCmapValues, BoxExtent } from '../types/maps'; import { Source } from '../types/maps'; import { NUMBER_OF_FIXED_COORDINATE_DECIMALS } from '../configs/mapSettings'; +import { Point } from 'ol/geom'; +import { Fill, Stroke, Style } from 'ol/style'; +import { FeatureLike } from 'ol/Feature'; /** * A utility function to format a layer's name. @@ -172,3 +175,26 @@ export function createSourcePopupContent( containerEl.appendChild(createSourceP('coord', data)); containerEl.appendChild(createSourceP('flux', data)); } + +/** + * Used to override default styling of the Draw feature so we can + * remove the blue Point that tracks the mouse cursor + */ +export function drawStyle(feature: FeatureLike) { + const geometry = feature.getGeometry(); + + // Hide the sketch point + if (geometry instanceof Point) { + return undefined; + } + + return new Style({ + stroke: new Stroke({ + color: '#3399CC', + width: 2, + }), + fill: new Fill({ + color: 'rgba(0, 0, 255, 0.1)', + }), + }); +}