require(["esri/geometry/operators/distanceOperator"], (distanceOperator) => { /* code goes here */ });
import * as distanceOperator from "@arcgis/core/geometry/operators/distanceOperator.js";
esri/geometry/operators/distanceOperator
Calculates planar distance between 2D geometries.
Property Overview
Name | Type | Summary | Object |
---|---|---|---|
Indicates if the operator supports input geometries that contain curves. | distanceOperator |
Property Details
-
supportsCurves
supportsCurves Booleanreadonly
-
Indicates if the operator supports input geometries that contain curves.
- Default Value:true
Method Overview
Name | Return Type | Summary | Object |
---|---|---|---|
Returns the planar distance between two geometries. | distanceOperator |
Method Details
-
execute
execute(geometry1, geometry2, options){Number}
-
Returns the planar distance between two geometries. Unless the
unit
option is set, the default is the spatial reference unit of the input geometries.Parametersgeometry1 GeometryUnionThe first input geometry.
geometry2 GeometryUnionThe second input geometry.
options ObjectoptionalAdditional options.
Specificationunit LengthUnitoptionalThe length unit of the distance. An error will be thrown if this is set for Geographic Coordinate Systems.
ReturnsType Description Number The distance between the two geometries. Can return NaN for empty geometries. Example// Calculate the planar distance between two points const distance = distanceOperator.execute(point1, point2);