diff --git a/lib/ReactViews/Custom/Chart/BottomDockChart.jsx b/lib/ReactViews/Custom/Chart/BottomDockChart.jsx index 6b355609b96..11044fad6c5 100644 --- a/lib/ReactViews/Custom/Chart/BottomDockChart.jsx +++ b/lib/ReactViews/Custom/Chart/BottomDockChart.jsx @@ -256,11 +256,11 @@ class Chart extends React.Component { () => this.props.terria.selectedStopSummaryRowIndex.fromTable, (idx) => { if (idx !== null && this.props.chartItems) { - let sumDistances = 0; - for (let i = idx; i > 0; i--) { - sumDistances += - this.props.terria.measurableGeom.stopGroundDistances[i]; - } + const sumDistances = + this.props.terria.measurableGeom.stopGroundDistances + .slice(0, idx) + .reverse() + .reduce((acc, distance) => acc + distance, 0); // Calculate the selected point coords in the chart. const selectedPoint = { diff --git a/lib/ReactViews/MeasurableGeometry/MeasurablePanel.tsx b/lib/ReactViews/MeasurableGeometry/MeasurablePanel.tsx index 8ca8f5466b0..46a18d4112d 100644 --- a/lib/ReactViews/MeasurableGeometry/MeasurablePanel.tsx +++ b/lib/ReactViews/MeasurableGeometry/MeasurablePanel.tsx @@ -419,19 +419,6 @@ const MeasurablePanel = observer((props: Props) => { ); }; - useEffect(() => { - if (terria.cesium) { - terria.cesium.scene.primitives.add(billboardCollection.current); - - return () => { - billboardCollection.current?.removeAll(); - terria.cesium - ? terria.cesium.scene.primitives.remove(billboardCollection.current) - : undefined; - }; - } - }, [terria]); - useEffect(() => { setHighlightedRow(terria.selectedStopSummaryRowIndex.fromChart); }, [terria.selectedStopSummaryRowIndex.fromChart]); @@ -442,24 +429,22 @@ const MeasurablePanel = observer((props: Props) => { terria.setSelectedStopSummaryRowIndex("fromTable", idx); const coords = terria?.measurableGeom?.stopPoints?.[idx]; if (!coords) return; + if (!terria.cesium) return; if (!billboardCollection.current) { - if (terria.cesium) { - billboardCollection.current = new BillboardCollection({ - scene: terria.cesium.scene - }); - terria.cesium.scene.primitives.add(billboardCollection.current); - } - } else { - billboardCollection.current.removeAll(); - billboardCollection.current.add({ - position: Cartographic.toCartesian(coords), - image: markerIcon, - eyeOffset: new Cartesian3(0.0, 0.0, -50.0), - heightReference: HeightReference.CLAMP_TO_GROUND, - disableDepthTestDistance: Number.POSITIVE_INFINITY, - id: "chartPointPlaceholder" + billboardCollection.current = new BillboardCollection({ + scene: terria.cesium.scene }); + terria.cesium.scene.primitives.add(billboardCollection.current); } + billboardCollection.current.removeAll(); + billboardCollection.current.add({ + position: Cartographic.toCartesian(coords), + image: markerIcon, + eyeOffset: new Cartesian3(0.0, 0.0, -50.0), + heightReference: HeightReference.CLAMP_TO_GROUND, + disableDepthTestDistance: Number.POSITIVE_INFINITY, + id: "chartPointPlaceholder" + }); terria.currentViewer.notifyRepaintRequired(); };