ESRI API function (REST/JAVASCRIPT) to find nearest feature of a coordinate

911
1
07-06-2020 12:18 AM
AdeebFarhan
New Contributor II

Dears

I have a an array of coordinates in my JavaScript program. I am processing these coordinates in a loop.

 

I need to find the nearest feature of each of these coordinate. The feature I am looking for is available in a map service published in our local server. I need to find the nearest feature in the JavaScript loop itself without manual interventions.

 

Is there any ESRI JavaScript or REST API function available for finding the nearest feature of the selected coordinate? 

 

Could you please provide the API functions and detailed steps to use it?

 

I am using the ArcGIS JavaScript API version 3.14 (js.arcgis.com/3.14compact).

Our ArcGIS server version is 10.2

0 Kudos
1 Reply
GavinRehkemper
Esri Contributor

The latest version of the ArcGIS API for JavaScript version 3 (v3.32) has a method called "nearestVertex" - would that work for you?

esri/geometry/geometryEngine | API Reference | ArcGIS API for JavaScript 3.32 

(you may have to check that this exists at your version, or update to v3.32)

0 Kudos