Added a scale and unit option to the measure tool

This commit is contained in:
Mitchell McCaffrey
2020-08-04 10:31:31 +10:00
parent f58884c82c
commit 96ff9a9fa3
3 changed files with 32 additions and 4 deletions

View File

@@ -21,6 +21,12 @@ function MapMeasure({ selectedToolSettings, active, gridSize }) {
const [drawingShapeData, setDrawingShapeData] = useState(null);
const [isBrushDown, setIsBrushDown] = useState(false);
const toolScale =
active && selectedToolSettings.scale.match(/(\d*)([a-zA-Z]*)/);
const toolMultiplier =
active && !isNaN(parseInt(toolScale[1])) ? parseInt(toolScale[1]) : 1;
const toolUnit = active && toolScale[2];
useEffect(() => {
if (!active) {
return;
@@ -126,7 +132,9 @@ function MapMeasure({ selectedToolSettings, active, gridSize }) {
>
<Tag fill="hsla(230, 25%, 18%, 0.8)" cornerRadius={4} />
<Text
text={shapeData.length.toFixed(2)}
text={`${(shapeData.length * toolMultiplier).toFixed(
2
)}${toolUnit}`}
fill="white"
fontSize={24}
padding={4}