AMD:
require(["esri/geometry/operators/distanceOperator"], (distanceOperator) => { /* code goes here */ });
ESM:
import * as distanceOperator from "@arcgis/core/geometry/operators/distanceOperator.js";
Object:
esri/geometry/operators/distanceOperator
Since: ArcGIS Maps SDK for JavaScript 4.31
beta
Calculates distance between 2D geometries.
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 GeometryThe first input geometry.
geometry2 GeometryThe 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 distance between two points const distance = distanceOperator.execute(point1, point2);