Hello Everyone,
I am trying to customize the dropdown menu from the measurement widget. I want to keep only the metric units and remove other units from the drop down menu.
Is it possible in 4.25 version?
Thank you so much in advance.
This appears to work:
const measurement = new Measurement({
areaUnit: "hectares",
linearUnit: "kilometers"
});
measurement.viewModel.watch("activeViewModel", function(newValue, oldValue, propertyName, target) {
if (newValue) {
switch (newValue.declaredClass) {
case "esri.widgets.AreaMeasurement3D.AreaMeasurement3DViewModel":
case "esri.widgets.AreaMeasurement2D.AreaMeasurement2DViewModel":
newValue.unitOptions = ["square-millimeters","square-centimeters","square-decimeters","square-meters","square-kilometers","ares","hectares"];
break;
case "esri.widgets.DirectLineMeasurement3D.DirectLineMeasurement3DViewModel":
case "esri.widgets.DistanceMeasurement2D.DistanceMeasurement2DViewModel":
newValue.unitOptions = ["millimeters","centimeters","decimeters","meters","kilometers"];
break;
}
}
});