import * as proximityOperator from "@arcgis/core/geometry/operators/proximityOperator.js";
const proximityOperator = await $arcgis.import("@arcgis/core/geometry/operators/proximityOperator.js");
@arcgis/core/geometry/operators/proximityOperator
Find the closest vertices of the 2D geometry.

Property Overview
| Name | Type | Summary | Object |
|---|---|---|---|
Indicates if the operator supports input geometries that contain curves. | proximityOperator |
Property Details
-
supportsCurves
PropertysupportsCurves Booleanreadonly -
Indicates if the operator supports input geometries that contain curves. The value will always be
true.
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
MethodgetNearestCoordinate(geometry, point, options){ProximityResult} -
Returns the nearest coordinate on the geometry to the given input point.
ParametersSpecificationgeometry GeometryUnionThe input geometry.
point PointThe point used to search for the nearest coordinate in
geometry.options ObjectoptionalAdditional options.
SpecificationcalculateLeftRightSide BooleanoptionalDefault Value: falseWhen 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
isRightSideproperty of the returnedProximityResultobject.testPolygonInterior BooleanoptionalDefault Value: trueWhen
geometryis a polygon, the function will test ifpointis 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 LengthUnitoptionalThe length unit of the result distance. The default is the input geometry's spatial reference unit. An error will be thrown if this is set for Geographic Coordinate Systems.
ReturnsType Description 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 point const proximityResult = proximityOperator.getNearestCoordinate(polygon, point);
-
getNearestVertex
MethodgetNearestVertex(geometry, point, options){ProximityResult} -
Returns the nearest vertex on the geometry.
Parametersgeometry GeometryUnionThe input geometry.
point PointThe point used to search for the nearest coordinate in the input
geometry.options ObjectoptionalAdditional options.
Specificationunit LengthUnitoptionalThe length unit of the result distance. The default is the input geometry's spatial reference unit. An error will be thrown if this is set for Geographic Coordinate Systems.
ReturnsType Description 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 point const proximityResult = proximityOperator.getNearestVertex(polygon, point);
-
getNearestVertices
MethodgetNearestVertices(geometry, point, searchRadius, maxVertexCountToReturn, options){ProximityResult[]} -
Returns vertices of the geometry that are closer to the given point than the given radius.
Parametersgeometry GeometryUnionThe input geometry.
point PointThe point used to search for the nearest coordinate in
geometry.searchRadius NumberThe planar distance from the
inputPointto search for vertices. Unless theunitoption is set, the default is the geometry's spatial reference unit.maxVertexCountToReturn NumberThe maximum number of vertices that will be returned. Must be a positive number.
options ObjectoptionalAdditional options.
Specificationunit LengthUnitoptionalThe 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.
ReturnsType Description 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 point const proximityResultsArray = proximityOperator.getNearestVertices(polygon, point, 100, 5);
Type Definitions
-
Object returned from the getNearestCoordinate(), getNearestVertex(), and getNearestVertices() methods.
- Properties
-
coordinate Point
The nearest coordinate on the geometry to the given input point.
distance NumberThe planar distance between the input point and the nearest coordinate on the geometry. Unless the
unitoption is set, the default is the spatial reference unit of the input geometries.isEmpty BooleanIndicates if the result is empty.
optionalisRightSide BooleanIndicates if the nearest coordinate is on the right side or left side of the input point.
Note: This property will only be present when
calculateLeftRightSideis set totruewhen callinggetNearestCoordinate().vertexIndex NumberThe index of the vertex on the geometry that is closest to the input point.