I want to pass a feature service as an input(Input parameter type -GPFeatureRecordSetLayer) to a geoprocessing service. can anyone tell me a sample code? I read all the relevant questions available, but I didn't find an answer in which feature service is used as an input.
-
1As per the Tour there should be only one question asked per question.– PolyGeo ♦Commented Mar 26, 2019 at 11:38
-
Are you essentially asking how do I pass a feature service as input to a geoprocessing service?– KHibmaCommented Mar 26, 2019 at 17:18
-
Yes.you are correct.– Shanaka HerathCommented Mar 27, 2019 at 0:26
-
To-PolyGeo-I have edited my question– Shanaka HerathCommented Mar 27, 2019 at 4:05
Add a comment
|
1 Answer
You can find an example of this in the 3rd demo of the ZIP file from my presentation Creating Geoprocessing Services UC2014.
While this presentation is 5 years old and the MapServiceIn_FSDraw.html file references the 3.8 JS API, the patterns remain the same for the newer APIS.
Here's a cut/paste of some relevant code:
var inputLayerUrl = "http://xxxx.arcgis.com/xxxxx/arcgis/rest/services/Service/FeatureServer/0";
var inputLayer = new esri.layers.FeatureLayer(inputLayerUrl,{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: ["reportedNumber"],
opacity:.50
});
map.addLayer(inputLayer);
//use the map extent to select features
var selectQuery = new Query();
selectQuery.geometry = map.extent;
inputLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW);
//"Input_Features" is the name of the input parameter
params.Input_features = inputLayer;
//Task (geoprocessor is assumed to be already setup)
task.submitJob(params, taskComplete, taskStatus, taskError);