How to use the findNearest arcgis javascript api? Is there any sample how to use findnearest api??
I have used something like :
$scope.findNearest = new www.FindNearest({
analysisLayer: analysisLayer, //this is the graphics layer type: polygon
nearLayers: nearLayers, //this is a feature layer get from quering arcgis url like: https://something.com/MapServer/0?f=pjson
map: $scope.map,
portalUrl: "https://domain/arcgis/rest/services/Utilities/Geometry/GeometryServer"
}, "analysis-tool");
It does not work.. I hope someone could suggest me on this.
Suraj,
Some of your code looks strange:
$scope.findNearest = new www.FindNearest({
analysisLayer: analysisLayer, //this is the graphics layer type: polygon
nearLayers: nearLayers, //this is a feature layer get from quering arcgis url like: https://something.com/MapServer/0?f=pjson
map: $scope.map,
portalUrl: "https://domain/arcgis/rest/services/Utilities/Geometry/GeometryServer"
}, "analysis-tool");
You can find the expected/required properties in the help doc:
FindNearest | API Reference | ArcGIS API for JavaScript 3.24
Hi Robert,
Thanks for your reply. I have copied code sample from my project directly, so it looks bit strange. From your suggestions, it seems incorrect to use graphics layer to search nearest feature layer using FindNearest esri api.
Could you suggest us right esri api to use in order to find nearest feature layer by using polygon graphics? Currently, we only get result from FindNearest api if the drawn polygon graphics contains feature layer, but if the polygon lies outside the layer, we get no result.
Thanks.
Hi Suraj
Analysis Widgets/Dijits work against ArcGIS Spatial Analysis Service, I recommend looking at the Working with Analysis Widgets | Guide | ArcGIS API for JavaScript 3.24 Guide to working with Analysis Widgets and Samples on the documentation pages. Hope this helps
Thanks and Regards
Ganesh Subbiah