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
beta

Calculates distance between 2D geometries.

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 Geometry

The first input geometry.

geometry2 Geometry

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