From 8b6ad03a58088085b7072667d4e6958dcbccb0db Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Wed, 28 Oct 2020 15:16:38 -0400 Subject: [PATCH] Fix issue where switching between metric/imperial measurements wouldn't work --- modules/ui/panels/measurement.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/ui/panels/measurement.js b/modules/ui/panels/measurement.js index ef799c01f..20be05d66 100644 --- a/modules/ui/panels/measurement.js +++ b/modules/ui/panels/measurement.js @@ -35,12 +35,13 @@ export function uiPanelMeasurement(context) { return result; } + var _isImperial = !localizer.usesMetric(); function redraw(selection) { var graph = context.graph(); var selectedNoteID = context.selectedNoteID(); var osm = services.osm; - var isImperial = !localizer.usesMetric(); + var localeCode = localizer.localeCode(); var heading; @@ -144,7 +145,7 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.area') + ':') .append('span') - .html(displayArea(area, isImperial)); + .html(displayArea(area, _isImperial)); } if (length) { @@ -152,7 +153,7 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.' + (closed ? 'perimeter' : 'length')) + ':') .append('span') - .html(displayLength(length, isImperial)); + .html(displayLength(length, _isImperial)); } if (typeof distance === 'number') { @@ -160,7 +161,7 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.distance') + ':') .append('span') - .html(displayLength(distance, isImperial)); + .html(displayLength(distance, _isImperial)); } if (location) { @@ -194,7 +195,7 @@ export function uiPanelMeasurement(context) { } if (length || area || typeof distance === 'number') { - var toggle = isImperial ? 'imperial' : 'metric'; + var toggle = _isImperial ? 'imperial' : 'metric'; selection .append('a') .html(t.html('info_panels.measurement.' + toggle)) @@ -202,7 +203,7 @@ export function uiPanelMeasurement(context) { .attr('class', 'button button-toggle-units') .on('click', function(d3_event) { d3_event.preventDefault(); - isImperial = !isImperial; + _isImperial = !_isImperial; selection.call(redraw); }); }