import { getNearestCoordinate, getNearestVertex, getNearestVertices, supportsCurves } from "@arcgis/core/geometry/operators/proximityOperator.js";const { getNearestCoordinate, getNearestVertex, getNearestVertices, supportsCurves } = await $arcgis.import("@arcgis/core/geometry/operators/proximityOperator.js");- Since
- ArcGIS Maps SDK for JavaScript 4.31
Find the closest vertices of the 2D geometry.

- See also
Type definitions
Options
unit
- 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.
GetNearestCoordinateOptions
- Supertypes
- Options
testPolygonInterior
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
Functions
getNearestCoordinate
Returns the nearest coordinate on the geometry to the given input point.
- Signature
-
getNearestCoordinate (geometry: GeometryUnion, point: Point, options?: GetNearestCoordinateOptions): ProximityResult
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry. | | |
| point | The point used to search for the nearest coordinate in | | |
| options | Additional options. | |
- Returns
- ProximityResult
Returns the proximity result which contains the nearest coordinate on the input
geometryto the giveninputPoint.
Example
// Return the nearest result on a polygon to the given pointconst proximityResult = proximityOperator.getNearestCoordinate(polygon, point); getNearestVertex
Returns the nearest vertex on the geometry.
- Signature
-
getNearestVertex (geometry: GeometryUnion, point: Point, options?: Options): ProximityResult
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry. | | |
| point | The point used to search for the nearest coordinate in the input | | |
| options | Additional options. | |
- Returns
- ProximityResult
Returns the proximity result which contains the nearest vertex on the
geometryto the giveninputPoint.
Example
// Return the nearest vertex on a polygon to the given pointconst proximityResult = proximityOperator.getNearestVertex(polygon, point); getNearestVertices
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?: Options): ProximityResult[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry. | | |
| point | The point used to search for the nearest coordinate in | | |
| searchRadius | The planar distance from the | | |
| 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
geometryto the giveninputPointthat are less than or equal to the planar distance of search radius. The array is sorted by distance to theinputPointwith the closest point first. When there are more than themaxVertexCountToReturnvertices to return, it returns the closest vertices. The array will be empty whengeometryis empty.
Example
// Return the nearest vertices on a polygon to the given pointconst proximityResultsArray = proximityOperator.getNearestVertices(polygon, point, 100, 5);Variables
supportsCurves
Indicates if the operator supports input geometries that contain curves.
The value will always be true.
- Type
- boolean