Skip to content
import { execute, 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

Options

Type definition

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.

Functions

NameReturn TypeObject

execute

Function

Returns the planar distance between two geometries.

Signature
execute (geometry1: GeometryUnion, geometry2: GeometryUnion, options?: Options): 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 = distanceOperator.execute(point1, point2);

Variables

supportsCurves

Variable

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

Type
boolean