AreaMeasurement2DViewModel

require(["esri/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel"], function(AreaMeasurement2DViewModel) { /* code goes here */ });
Class: esri/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel
Inheritance: AreaMeasurement2DViewModel Accessor
Since: ArcGIS API for JavaScript 4.10

Provides the logic for the AreaMeasurement2D widget.

See also:

Constructors

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

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
Number

The threshold distance used by the "auto" mode to switch between planar and geodesic linear computations.

more details
more detailsAreaMeasurement2DViewModel
Object

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

more details
more detailsAreaMeasurement2DViewModel
Object

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

more details
more detailsAreaMeasurement2DViewModel
String

The mode used to calculate the area and perimeter of a polygon.

more details
more detailsAreaMeasurement2DViewModel
String[]

An array of valid mode values.

more details
more detailsAreaMeasurement2DViewModel
String

The ViewModel's state.

more details
more detailsAreaMeasurement2DViewModel
String

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

more details
more detailsAreaMeasurement2DViewModel
String[]

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

more details
more detailsAreaMeasurement2DViewModel
MapView

The view from which the widget will operate.

more details
more detailsAreaMeasurement2DViewModel

Property Details

geodesicDistanceThreshold Number

The threshold distance used by the "auto" mode to switch between planar and geodesic linear computations. The threshold is measured in meters.

Default Value:100000
Example:
// To set the threshold at 10 km
var measurementWidget = new AreaMeasurement2D({
  viewModel: {
    view: view,
    geodesicDistanceThreshold: 10000
  }
});
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
var measurementWidget = new AreaMeasurement2D({
  view: view
});
view.ui.add(measurementWidget, "top-right");

// Raw measurements (in meters) can be accessed from this property
measurementWidget.watch("viewModel.measurement", function(measurement) {
  console.log(
     "Area: ", measurement.area,
     "Perimeter: ", measurement.perimeter
  );
});
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 and mode.

Properties:
area Number

The area (m²).

perimeter Number

The perimeter (m).

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

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

The mode used to calculate the area and perimeter of a polygon.

Possible Values: auto | planar | geodesic

Default Value:auto
Example:
// To create the AreaMeasurement2D widget that uses geodesic computations
var measurementWidget = new AreaMeasurement2D({
  viewModel: {
    view: view,
    mode: "geodesic"
  }
});

// To display the current mode.
console.log("Current mode: ", measurementWidget.viewModel.mode);
modes String[]readonly

An array of valid mode values. By default, the following units are included: auto, planar, geodesic.

Example:
// To display the available modes in the console
var measurementWidget = new AreaMeasurement2D({
  view: view
});
console.log("All modes: ", measurementWidget.viewModel.modes.join(", "));
state Stringreadonly

The ViewModel's state.

Possible Values: disabled | ready | measuring | measured

ValueDescription
disablednot ready yet
readyready for measuring
measuringmeasuring has started
measuredmeasuring has finished
Default Value:disabled
Example:
// To display the state of the AreaMeasurement2D widget
var measurementWidget = new AreaMeasurement2D({
  view: view
});
measurementWidget.watch("viewModel.state", function(state){
  console.log("Current state: ", state);
});
unit String

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

Possible Values: metric | imperial | square-inches | square-feet | square-us-feet | square-yards | square-miles | square-meters | square-kilometers | acres | ares | hectares

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

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

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.

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

The view from which the widget will operate.

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

Method Overview

NameReturn TypeSummaryClass

Clears the current measurement.

more details
more detailsAreaMeasurement2DViewModel

Starts a new measurement.

more details
more detailsAreaMeasurement2DViewModel

Method Details

clearMeasurement()

Clears the current measurement.

newMeasurement()

Starts a new measurement.

API Reference search results

NameTypeModule
Loading...