distanceOperator

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

Calculates planar distance between 2D geometries.

Distance operator

Property Overview

Name Type Summary Object

Indicates if the operator supports input geometries that contain curves.

distanceOperator

Property Details

supportsCurves

Property
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

Method
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.

Parameters
geometry1 GeometryUnion

The first input geometry.

geometry2 GeometryUnion

The second input geometry.

options Object
optional

Additional options.

Specification
unit LengthUnit
optional

The length unit of the distance. An error will be thrown if this is set for Geographic Coordinate Systems.

Returns
Type 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);

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.