AreaMeasurement2DViewModel

AMD: require(["esri/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel"], (AreaMeasurement2DViewModel) => { /* code goes here */ });
ESM: import AreaMeasurement2DViewModel from "@arcgis/core/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.js";
Class: esri/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel
Inheritance: AreaMeasurement2DViewModel Accessor
Since: ArcGIS Maps SDK for JavaScript 4.10

Provides the logic for the AreaMeasurement2D widget.

See also

Constructors

AreaMeasurement2DViewModel

Constructor
new AreaMeasurement2DViewModel(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Name Type Summary Class

Threshold (in meters) which determines the method for computing and displaying areas and perimeters in non-Web Mercator projected coordinate systems (PCS).

AreaMeasurement2DViewModel

The area and perimeter of the measurement polygon in square meters and meters respectively.

AreaMeasurement2DViewModel

This property returns the locale specific representation of the area and perimeter.

AreaMeasurement2DViewModel

The ViewModel's state.

AreaMeasurement2DViewModel

Unit system (imperial, metric) or specific unit used for displaying the area values.

AreaMeasurement2DViewModel

List of available units and unit systems (imperial, metric) for displaying the area values.

AreaMeasurement2DViewModel

The view from which the widget will operate.

AreaMeasurement2DViewModel

Property Details

geodesicDistanceThreshold

Property
geodesicDistanceThreshold Number
Deprecated since version 4.29.

Threshold (in meters) which determines the method for computing and displaying areas and perimeters in non-Web Mercator projected coordinate systems (PCS).

  • Below this threshold, they are computed in a Euclidean manner (in their respective PCS).
  • Above this threshold, they are computed geodetically.

If the threshold is omitted (default), areas and perimeters are always computed in a Euclidean manner.

This property is ignored if the map’s spatial reference is a geographic coordinate system (GCS) or Web Mercator. Meaning that areas and perimeters are always computed geodetically.

Default Value:null
Example
// To set the threshold at 10 km
let measurementWidget = new AreaMeasurement2D({
  viewModel: {
    view: view,
    geodesicDistanceThreshold: 10000
  }
});

measurement

Property
measurement Objectreadonly

The area and perimeter of the measurement polygon in square meters and meters respectively.

Properties
area Number

The area (m²).

perimeter Number

The perimeter (m).

geometry Polygon

Measurement area.

Example
// After creating and adding the AreaMeasurement2D widget
let measurementWidget = new AreaMeasurement2D({
  view: view
});
view.ui.add(measurementWidget, "top-right");

// Raw measurements (in meters) can be accessed from this property
reactiveUtils.watch(
() => measurementWidget.viewModel.measurement,
  (measurement) => {
    console.log(
       "Area: ", measurement.area,
       "Perimeter: ", measurement.perimeter
    );
  }
);

measurementLabel

Property
measurementLabel Objectreadonly

This property returns the locale specific representation of the area and perimeter. Areas and perimeters are rounded to two decimal places. Areas are sourced from the measurement property (in square meters) and converted to the user defined units/system.

Properties
area Number

The area (m²).

perimeter Number

The perimeter (m).

Example
// After creating and adding the AreaMeasurement2D widget
let measurementWidget = new AreaMeasurement2D({
  view: view
});
view.ui.add(measurementWidget, "top-right");

// Measurement labels can be accessed from this property
reactiveUtils.watch(
() => measurementWidget.viewModel.measurementLabel,
  (label) => {
    console.log(
       "Area: ", label.area,
       "Perimeter: ", label.perimeter
    );
  }
);

state

Property
state Stringreadonly

The ViewModel's state.

Value Description
disabled not ready yet
ready ready for measuring
measuring measuring has started
measured measuring has finished

Possible Values:"disabled" |"ready" |"measuring" |"measured"

Default Value:disabled
Example
// To display the state of the AreaMeasurement2D widget
let measurementWidget = new AreaMeasurement2D({
  view: view
});
reactiveUtils.watch(
  () => measurementWidget.viewModel.state,
  (state) => console.log("Current state: ", state)
);

unit

Property
unit SystemOrAreaUnit

Unit system (imperial, metric) or specific unit used for displaying the area values. Possible values are listed in unitOptions.

Example
// To create the AreaMeasurement2D widget that displays area in square US feet
let measurementWidget = new AreaMeasurement2D({
  viewModel: {
    view: view,
    unit: "square-us-feet"
  }
});

// To display the current measurement unit
console.log('Current unit: ', measurementWidget.viewModel.unit);

unitOptions

Property
unitOptions SystemOrAreaUnit[]

List of available units and unit systems (imperial, metric) for displaying the area values. By default, the following units are included: metric, imperial, square-inches, square-feet, square-us-feet, square-yards, square-miles, square-meters, square-kilometers, acres, ares, hectares. Possible unit values can only be a subset of this list.

Example
// To display the available units to the console
let measurementWidget = new AreaMeasurement2D({
  view: view
});
console.log('All units: ', measurementWidget.viewModel.unitOptions.join(", "));

view

Property
view MapView

The view from which the widget will operate.

Example
// To create the AreaMeasurement2D widget with the view property
let measurementWidget = new AreaMeasurement2D({
  viewModel: {
    view: view
  }
});

Method Overview

Name Return Type Summary Class

Clears the current measurement.

AreaMeasurement2DViewModel

Starts a new measurement.

AreaMeasurement2DViewModel

Method Details

clear

Method
clear()
Since: ArcGIS Maps SDK for JavaScript 4.16 AreaMeasurement2DViewModel since 4.10, clear added at 4.16.

Clears the current measurement.

start

Method
start()
Since: ArcGIS Maps SDK for JavaScript 4.16 AreaMeasurement2DViewModel since 4.10, start added at 4.16.

Starts a new measurement.

Example
const areaMeasurement2DViewModel = new AreaMeasurement2DViewModel({
  view: view,
  unit: "square-yards"
});

await areaMeasurement2DViewModel.start();

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.