AnsweredAssumed Answered

How to use a Spatial Analysis Service - FindNearest with JS api

Question asked by deleted-user-VeZur_n9o0OZ on Mar 4, 2014
Latest reply on Mar 19, 2014 by ganeshssac
Hello all,

I've seen similar questions to this but nothing with my specific symptoms so I've started a new thread. I'm trying to use the FindNearest Spatial Analysis Service. I have an AGOL org account, and am using a private webmap which requires me to login.

Through a combination of the above resources I've put together some code to submit a job. My job fails with the following errors relating to my input params...

ERROR 000735: analysisLayer: Value is required arcgis.js:62 ERROR 000735: nearLayer: Value is required arcgis.js:62 Failed. 

What am I doing wrong?

 var gp = new Geoprocessor("");             var _params = {                 "analysisLayer": {                     "url": ""                     //"url": ""                     //"filter" : "filter"                 },                 "NearLayer": {                     "layerDefinition": {                         "geometryType": "esriGeometryPoint",                         "fields": [                             {                                 "name": "Id",                                 "type": "esriFieldTypeOID",                                 "alias": "Id"                             }                         ]},                     "featureSet": {                         "geometryType": "esriGeometryPoint",                         "spatialReference": {                             "wkid": 4326                         },                         "features": [                             {                                 "geometry": {                                     "x": -94.00,                                     "y": 28.00                                 },                                 "attributes": {                                     "Id": 1                                 }                             }                         ]}                 },                 "maxCount": 10,                 "measurementType": "StraightLine",                 //"searchCutoff": 44,                 //"searchCutoffUnits": "Kilometers"                 "f": "json"             }             gp.submitJob(_params, completeCallback, statusCallback, errorCallback);

Also, how would I get the required authentication if I make my webmap and feature service public? Portal class?