proximityOperator

AMD: require(["esri/geometry/operators/proximityOperator"], (proximityOperator) => { /* code goes here */ });
ESM: import * as proximityOperator from "@arcgis/core/geometry/operators/proximityOperator.js";
Object: esri/geometry/operators/proximityOperator
Since: ArcGIS Maps SDK for JavaScript 4.31
beta

Find the closest vertices of the 2D geometry.

Method Overview

Name Return Type Summary Object

Returns the nearest coordinate on the geometry to the given input point.

proximityOperator

Returns the nearest vertex on the geometry.

proximityOperator

Returns vertices of the geometry that are closer to the given point than the given radius.

proximityOperator

Method Details

getNearestCoordinate

Method
getNearestCoordinate(geometry, point, options){ProximityResult}

Returns the nearest coordinate on the geometry to the given input point.

Parameters
Specification
geometry Geometry

The input geometry.

point Point

The point used to search for the nearest coordinate in geometry.

options Object
optional

Additional options.

Specification
calculateLeftRightSide Boolean
optional
Default Value: false

When the parameter is set to true, this function will calculate the left/right side of a polyline or polygon. Look for the result in the rightSide property of the returned ProximityResult object.

testPolygonInterior Boolean
optional
Default Value: true

When geometry is a polygon, the function will test if point is inside of the polygon. Points that are inside of the polygon have zero distance to the polygon. When set to false, the function will not check if the point is inside of the polygon, but will only determine proximity to the boundary.

unit LengthUnit
optional

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

Returns
Type Description
ProximityResult Returns the proximity result which contains the nearest coordinate on the input geometry to the given inputPoint.
Example
// Return the nearest result on a polygon to the given point
const proximityResult = proximityOperator.getNearestCoordinate(polygon, point);

getNearestVertex

Method
getNearestVertex(geometry, point, options){ProximityResult}

Returns the nearest vertex on the geometry.

Parameters
geometry Geometry

The input geometry.

point Point

The point used to search for the nearest coordinate in the input geometry.

options Object
optional

Additional options.

Specification
unit LengthUnit
optional

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

Returns
Type Description
ProximityResult Returns the proximity result which contains the nearest vertex on the geometry to the given inputPoint.
Example
// Return the nearest vertex on a polygon to the given point
const proximityResult = proximityOperator.getNearestVertex(polygon, point);

getNearestVertices

Method
getNearestVertices(geometry, point, searchRadius, maxVertexCountToReturn, options){ProximityResult[]}

Returns vertices of the geometry that are closer to the given point than the given radius.

Parameters
geometry Geometry

The input geometry.

point Point

The point used to search for the nearest coordinate in geometry.

searchRadius Number

The planar distance from the inputPoint to search for vertices. Unless the unit option is set, the default is the geometry's spatial reference unit.

maxVertexCountToReturn Number

The maximum number of vertices that will be returned. Must be a positive number.

options Object
optional

Additional options.

Specification
unit LengthUnit
optional

The length unit of the search radius and result distances. An error will be thrown if this is set for Geographic Coordinate Systems.

Returns
Type Description
ProximityResult[] Returns an array of proximity results which contain the nearest vertices on geometry to the given inputPoint that are less than or equal to the planar distance of search radius. The array is sorted by distance to the inputPoint with the closest point first. When there are more than the maxVertexCountToReturn vertices to return, it returns the closest vertices. The array will be empty when geometry is empty.
Example
// Return the nearest vertices on a polygon to the given point
const proximityResultsArray = proximityOperator.getNearestVertices(polygon, point, 100, 5);

Type Definitions

ProximityResult

Type Definition
ProximityResult

Object returned from the getNearestCoordinate(), getNearestVertex(), and getNearestVertices() methods.

Properties
coordinate Point

The nearest coordinate on the geometry to the given input point.

distance Number

The planar distance between the input point and the nearest coordinate on the geometry. Unless the unit option is set, the default is the spatial reference unit of the input geometries.

isEmpty Boolean

Indicates if the result is empty.

isRightSide Boolean
optional

Indicates if the nearest coordinate is on the right side or left side of the input point. This property will only be present when calculateLeftRightSide is set to true when calling getNearestCoordinate().

vertexIndex Number

The index of the vertex on the geometry that is closest to the input point.

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