1

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 take a look at my code and tell me how I reference a feature set from the editor widget results?

], 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();



    }



     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 selectGraphics = featureLayer.getSelectedFeatures();

    features.push(selectGraphics);
    var featureSet = new esri.tasks.FeatureSet();

    featureSet.features = features;


    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);
    }
  }
  • This isn't at all easy to follow. The code you've included looks like a partial snapshot of a much larger code base, and the intent is far from clear. Can you consider trying to make a smaller sample that shows the particular issue you need help with? – BradHards Oct 8 '13 at 3:29
1

Looks like you're very close, have a look at the following URLs: https://developers.arcgis.com/javascript/jshelp/intro_gp_creating.html https://developers.arcgis.com/javascript/jshelp/intro_gp_parameters.html https://developers.arcgis.com/javascript/jshelp/intro_gp_running.html

One thing to check is that execute is for synchronous GP tasks and submitJob is for async tasks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.