import { isLoaded, load, getNearestCoordinate, getNearestVertex, getNearestVertices } from "@arcgis/core/geometry/operators/geodesicProximityOperator.js";const { isLoaded, load, getNearestCoordinate, getNearestVertex, getNearestVertices } = await $arcgis.import("@arcgis/core/geometry/operators/geodesicProximityOperator.js");- Since
- ArcGIS Maps SDK for JavaScript 4.31
Finds closest vertices of a 2D geometry using geodesic distance.
Notes
Verify that isLoaded() returns true before using this module.
Use load() to load this module's dependencies.

Type definitions
Options
unit
- Type
- LengthUnit | undefined
The length unit of the result distance.
- Default value
- "meters"
GetNearestCoordinateOptions
- Supertypes
- Options
maxDeviation
The value controls the error of calculation.
The method uses shape preserving densification to approximate the input segments with great piecewise elliptical arcs.
When the value is zero or NaN, internally the operator uses 0.01 meters.
For other values, unless the unit option is set, the default is meters.
- Default value
- NaN
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
isLoaded
Indicates if all dependencies of this module have been loaded.
- Signature
-
isLoaded (): boolean
- Returns
- boolean
Returns
trueif this module's dependencies have been loaded.
load
Loads this module's dependencies. This method must be called first if isLoaded returns false.
- See also
- Signature
-
load (): Promise<void>
getNearestCoordinate
Returns the nearest coordinate on the geometry to the given input point. The operator interprets all segments in the shape preserving manner, that is it treats segments as if they are densified with a small step in the input spatial reference and then the calculation is performed geodesicly.
- 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 result of proximity operation.
Example
if (!geodesicProximityOperator.isLoaded()) { await geodesicProximityOperator.load();}
// Calculate the nearest coordinate on a polyline to the given pointconst result = geodesicProximityOperator.getNearestCoordinate(polyline, 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 result of proximity operation.
Example
if (!geodesicProximityOperator.isLoaded()) { await geodesicProximityOperator.load();}
// Calculate the nearest vertex on a polyline to the given pointconst result = geodesicProximityOperator.getNearestVertex(polyline, 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 distance to search from the | | |
| maxVertexCountToReturn | The maximum number of vertices that will be returned. Must be a positive number. | | |
| options | Additional options. | |
- Returns
- ProximityResult[]
The array of vertices that are in the given search radius to the point. The array is sorted by distance to the queryPoint with the closest point first. When there are more than the
maxVertexCountToReturnvertices to return, it returns the closest vertices. The array will be empty whengeometryis empty.
Example
if (!geodesicProximityOperator.isLoaded()) { await geodesicProximityOperator.load();}
// Calculate the nearest vertices on a polyline to the given pointconst result = geodesicProximityOperator.getNearestVertices(polyline, point, 100, 5);