import { distanceExecute, execute, distanceSupportsCurves, supportsCurves } from "@arcgis/core/geometry/operators/distanceOperator.js";
Since
ArcGIS Maps SDK for JavaScript 4.31

Calculates planar distance between 2D geometries.

Distance operator

See also

Type definitions

DistanceOptions

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.2

unit

Property
Type
LengthUnit | undefined

The length unit of the distance. The default is the input geometry's spatial reference unit. An error will be thrown if this is set for Geographic Coordinate Systems.

Options

deprecated Type definition
Supertypes
DistanceOptions

Functions

distanceExecute

Function
Since
ArcGIS Maps SDK for JavaScript 5.2

Returns the planar distance between two geometries.

Signature
distanceExecute (geometry1: GeometryUnion, geometry2: GeometryUnion, options?: DistanceOptions): number

Parameters

ParameterTypeDescriptionRequired
geometry1

The first input geometry.

geometry2

The second input geometry.

options

Additional options.

Returns
number

The distance between the two geometries. Can return NaN for empty geometries.

Example
// Calculate the planar distance between two points
const distance = distanceExecute(point1, point2);

execute

deprecated Function

Returns the planar distance between two geometries.

Signature
execute (geometry1: GeometryUnion, geometry2: GeometryUnion, options?: DistanceOptions): number

Parameters

ParameterTypeDescriptionRequired
geometry1

The first input geometry.

geometry2

The second input geometry.

options

Additional options.

Returns
number

The distance between the two geometries. Will return NaN if either input geometry is empty.

Example
// Calculate the planar distance between two points
const distance = distanceExecute(point1, point2);

Variables

distanceSupportsCurves

Variable
Since
ArcGIS Maps SDK for JavaScript 5.2

Indicates if the operator supports input geometries that contain curves. The value will always be true.

Type
boolean

supportsCurves

deprecated Variable

Indicates if the operator supports input geometries that contain curves. The value will always be true.

Type
ReturnType