import { proximityGetNearestCoordinate, getNearestCoordinate, proximityGetNearestVertex, getNearestVertex, proximityGetNearestVertices } from "@arcgis/core/geometry/operators/proximityOperator.js";
Since
ArcGIS Maps SDK for JavaScript 4.31

Find the closest vertices of the 2D geometry.

Proximity operator

See also

Type definitions

ProximityOptions

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.2

unit

Property
Type
LengthUnit | undefined

The length unit of the search radius and result distances. 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
ProximityOptions

ProximityGetNearestCoordinateOptions

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.2
Supertypes
ProximityOptions

calculateLeftRightSide

Property
Type
boolean | undefined

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 isRightSide property of the returned ProximityResult object.

Default value
false

testPolygonInterior

Property
Type
boolean | undefined

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.

Default value
true

GetNearestCoordinateOptions

deprecated Type definition

Functions

proximityGetNearestCoordinate

Function
Since
ArcGIS Maps SDK for JavaScript 5.2

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

Signature
proximityGetNearestCoordinate (geometry: GeometryUnion, point: Point, options?: ProximityGetNearestCoordinateOptions): ProximityResult

Parameters

ParameterTypeDescriptionRequired
geometry

The input geometry.

point

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

options

Additional options.

Returns
ProximityResult

Returns the proximity result which contains the nearest coordinate on the input geometry to the given point.

Example
// Return the nearest result on a polygon to the given point
const proximityResult = proximityGetNearestCoordinate(polygon, point);

getNearestCoordinate

deprecated Function

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

Signature
getNearestCoordinate (geometry: GeometryUnion, point: Point, options?: ProximityGetNearestCoordinateOptions): ProximityResult

Parameters

ParameterTypeDescriptionRequired
geometry

The input geometry.

point

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

options

Additional options.

Returns
ProximityResult

Returns the proximity result which contains the nearest coordinate on the input geometry to the given point.

Example
// Return the nearest result on a polygon to the given point
const proximityResult = proximityGetNearestCoordinate(polygon, point);

proximityGetNearestVertex

Function
Since
ArcGIS Maps SDK for JavaScript 5.2

Returns the nearest vertex on the geometry.

Signature
proximityGetNearestVertex (geometry: GeometryUnion, point: Point, options?: ProximityOptions): ProximityResult

Parameters

ParameterTypeDescriptionRequired
geometry

The input geometry.

point

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

options

Additional options.

Returns
ProximityResult

Returns the proximity result which contains the nearest vertex on the geometry to the given point.

Example
// Return the nearest vertex on a polygon to the given point
const proximityResult = proximityGetNearestVertex(polygon, point);

getNearestVertex

deprecated Function

Returns the nearest vertex on the geometry.

Signature
getNearestVertex (geometry: GeometryUnion, point: Point, options?: ProximityOptions): ProximityResult

Parameters

ParameterTypeDescriptionRequired
geometry

The input geometry.

point

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

options

Additional options.

Returns
ProximityResult

Returns the proximity result which contains the nearest vertex on the geometry to the given point.

Example
// Return the nearest vertex on a polygon to the given point
const proximityResult = proximityGetNearestVertex(polygon, point);

proximityGetNearestVertices

Function
Since
ArcGIS Maps SDK for JavaScript 5.2

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

Signature
proximityGetNearestVertices (geometry: GeometryUnion, point: Point, searchRadius: number, maxVertexCountToReturn: number, options?: ProximityOptions): ProximityResult[]

Parameters

ParameterTypeDescriptionRequired
geometry

The input geometry.

point

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

searchRadius

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

maxVertexCountToReturn

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

options

Additional options.

Returns
ProximityResult[]

Returns an array of proximity results which contain the nearest vertices on geometry to the given point that are less than or equal to the planar distance of search radius. The array is sorted by distance to the query point, with the closest vertex 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 = proximityGetNearestVertices(polygon, point, 100, 5);

getNearestVertices

deprecated Function

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

Signature
getNearestVertices (geometry: GeometryUnion, point: Point, searchRadius: number, maxVertexCountToReturn: number, options?: ProximityOptions): ProximityResult[]

Parameters

ParameterTypeDescriptionRequired
geometry

The input geometry.

point

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

searchRadius

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

maxVertexCountToReturn

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

options

Additional options.

Returns
ProximityResult[]

Returns an array of proximity results which contain the nearest vertices on geometry to the given point that are less than or equal to the planar distance of search radius. The array is sorted by distance to the query point, with the closest vertex 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 = proximityGetNearestVertices(polygon, point, 100, 5);

Variables

proximitySupportsCurves

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