AnsweredAssumed Answered

Editor Widget -  Where is the returned feature set?

Question asked by ionarawilson on Oct 7, 2013
Latest reply on Jul 23, 2015 by gettingready
I am calling a geoprocessing service in a web app. The geoprocessing service has one parameter (a feature set). But I am not sure how to find the parameter in the javascript code to send it to the geoprocessing since I am using an editor widget to first create the polygon and then run the geoprocessing service. Can you guys take a look at my code and tell me how I reference a feature set from the editor widget results? Thank you!

      dojo.require("esri.tasks.query");           var map;              require([         "esri/map", "esri/dijit/BasemapGallery", "esri/arcgis/utils",          "esri/toolbars/edit",             "esri/layers/ArcGISTiledMapServiceLayer",         "esri/layers/FeatureLayer",   "esri/tasks/query", "esri/tasks/QueryTask",         "esri/symbols/SimpleMarkerSymbol",         "esri/symbols/SimpleLineSymbol",          "esri/dijit/editing/Editor",            "esri/dijit/editing/TemplatePicker",         "esri/config",         "dojo/i18n!esri/nls/jsapi",            "dojo/_base/array", "dojo/parser", "dojo/keys",          "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/TitlePane",            "dojo/dom", "dojo/on",          "dojo/domReady!",         ], function(         Map, BasemapGallery, arcgisUtils, Edit,          ArcGISTiledMapServiceLayer, FeatureLayer,   Query, QueryTask,         SimpleMarkerSymbol, SimpleLineSymbol,          Editor, TemplatePicker,          esriConfig, jsapiBundle,         arrayUtils, parser, keys,        borderContainer, contentPane, titlePane,         dom, on       ) {         parser.parse();                 // snapping is enabled for this sample - change the tooltip to reflect this         jsapiBundle.toolbars.draw.start = jsapiBundle.toolbars.draw.start +  "<br>Press <b>ALT</b> to enable snapping";                 // refer to "Using the Proxy Page" for more information:  https://developers.arcgis.com/en/javascript/jshelp/ags_proxy.html         esriConfig.defaults.io.proxyUrl = "/proxy";                    esriConfig.defaults.geometryService = new esri.tasks.GeometryService("http://tfsgis-iisd01:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer");                  map = new Map("map", {            basemap: "hybrid",                     center: [-98.57, 30.98],           zoom: 6,           slider: true          });      map.on("layers-add-result", initEditor);            var ActivityArea = new FeatureLayer("http://tfsgis-iisd01:6080/arcgis/rest/services/MyMapService2/FeatureServer/1",{           mode: FeatureLayer.MODE_ONDEMAND,            outFields: ['*']         });          var ActivityPoint = new FeatureLayer("http://tfsgis-iisd01:6080/arcgis/rest/services/MyMapService2/FeatureServer/0",{           mode: FeatureLayer.MODE_ONDEMAND,            outFields: ['*']         });          var stewardship = new FeatureLayer("http://tfsgis-iisd01:6080/arcgis/rest/services/MyMapService2/FeatureServer/2",{           mode: FeatureLayer.MODE_ONDEMAND,            outFields: ['*']         });          map.addLayers([ActivityArea,ActivityPoint,stewardship]);                             function initEditor(evt) {             var templateLayers = arrayUtils.map(evt.layers, function(result){             return result.layer;               });           var templatePicker = new TemplatePicker({             featureLayers: templateLayers,             grouping: true,             rows: "auto",             columns: 3           }, "templateDiv");           templatePicker.startup();            var layers = arrayUtils.map(evt.layers, function(result) {             return { featureLayer: result.layer };           });           var settings = {             map: map,             templatePicker: templatePicker,             layerInfos: layers,             toolbarVisible: true,             createOptions: {               polylineDrawTools:[ Editor.CREATE_TOOL_FREEHAND_POLYLINE ],               polygonDrawTools: [ Editor.CREATE_TOOL_FREEHAND_POLYGON,                 Editor.CREATE_TOOL_CIRCLE,                 Editor.CREATE_TOOL_TRIANGLE,                 Editor.CREATE_TOOL_RECTANGLE               ]             },             toolbarOptions: {               reshapeVisible: true             }                   };                   var params = {settings: settings};               var myEditor = new Editor(params,'editorDiv');           //define snapping options           var symbol = new SimpleMarkerSymbol(             SimpleMarkerSymbol.STYLE_CROSS,              15,              new SimpleLineSymbol(               SimpleLineSymbol.STYLE_SOLID,                new Color([255, 0, 0, 0.5]),                5             ),              null           );           map.enableSnapping({             snapPointSymbol: symbol,             tolerance: 20,             snapKey: keys.ALT           });                myEditor.startup();                          }             //add the basemap gallery, in this case we'll display maps from ArcGIS.com including bing maps         var basemapGallery = new BasemapGallery({           showArcGISBasemaps: true,           map: map         }, "basemapGallery");         basemapGallery.startup();                  basemapGallery.on("error", function(msg) {           console.log("basemap gallery error:  ", msg);         });      var queryTask, query;   queryTask = new QueryTask("http://tfsgis-iisd01:6080/arcgis/rest/services/MyMapService2/FeatureServer/2");          query = new Query();         query.returnGeometry = false;   //query.geometry = map.extent;    query.outFields = ["*"];        query.where = "1=1" ;                   queryTask.executeForCount(query,function(count){                  dom.byId("info").innerHTML = count             });           //     on(dom.byId("button"),"click", function() { //         gp = new esri.tasks.Geoprocessor("http://tfsgis-iisd01:6080/arcgis/rest/services/CalcFeaturesStewardshipOneParameter3/GPServer/CalcFeaturesStewardshipOneParameter") //   gp.outSpatialReference = map.spatialReference //  //  //   //  var features= []; //     //       var layer=map.getLayer("stewardship") //   var featureSet = new esri.tasks.FeatureSet(); //  featureSet.features = layer.graphics; //  featureSet.fields = layer.fields; //  featureSet.geometryType = layer.geometryType; //  var params = {Stewardship:featureSet} //  //    gp.submitJob(params, completeCallback , statusCallback) //       // //   //        }); //   //  function completeCallback(jobInfo){ //        //      } //    //      function statusCallback(jobInfo) { //        var status = jobInfo.jobStatus; //        if(status === "esriJobFailed"){ //          alert(status); //          //        } //        else if (status === "esriJobSucceeded"){ //          alert(status); //        } //      }              });// end require

Outcomes