How to pass a FeatureLayer as an input parameter to GP service using JSAPI

07-01-2017 10:56 PM
New Contributor

Suppose that I have a simple buffer GP service and a several point featurelayers; how can I pass the chosen layer as an input parameter?
I have tried this
inputFeatures.features = map.getLayer("layer1").graphics

inputFeatures.fields = map.getLayer("layer1").fields
and many other ways but with no luck.
I would appreciate it if the solution was simple because I am not a professional

0 Kudos
3 Replies
Regular Contributor
0 Kudos
New Contributor

Hi  Evelyn Hernandez

Thank you for your answer, I have seen all of these examples and they are using simple event feature, it is easy to pass such features to the GP service but I have created a CSV layer and I want to pass it as featureSet parameter or if there is any way that I can upload the CSV file directly to the geoprocessing service it will help a lot, note that I have tried uncountable ways to upload or request the file but all ended with failure. I am not sure what is blocking my requests.

0 Kudos
Esri Regular Contributor

A sort sample code is here


var featuresEN = [];                                        //-------------create an array
featuresEN.push(graphicEN);                        //-------------push here the input graphics
var featureSetEN = new FeatureSet();          //-------------create a feature set
featureSetEN.features = featuresEN;           //--------------set the feature set feature equal with the graphic array

var params = {
"Input_Incident_Point": featureSetST,
"Input_Rescue_Mean_Point": featureSetEN,            //---------------set the feature set on the input parameters 
"Avoid_Depths_Below ": bathmeters
gp.execute(params, drawShipPath, errorEX);


I hope this help you.

0 Kudos