AnsweredAssumed Answered

Zoom to geoprocessor result

Question asked by Noodles484 on Aug 18, 2015
Latest reply on Aug 19, 2015 by Noodles484


   This should be pretty easy, but I've tried a bunch of stuff and cant get it to work.  How do I zoom to the newly outputted feature layer created by a geoprocessing service I create.  Here is the code for I use to create it.  I've tried the commented out method for setting the map's extent with the test1 and test2 variables, but it doesn't work.




function gpJobComplete(jobinfo) {

  //get the result map service layer and add to map

  gp.getResultImageLayer(jobinfo.jobId, null, null, function (layer) {

    layer.setOpacity(0.7); = "Created Mammal Data";




  // var zoomLayer = map.getLayer('Created Mammal Data');

  // var test1 = webMercatorUtils.geographicToWebMercator(zoomLayer.fullExtent);

  // var test2 = zoomLayer.fullExtent;

  // map.setExtent(test1, true);


  map.on("layers-add-result", function (evtObj) {'legendWrapper'));

      if (!legend) {

        var layerInfo =, function (layer, index) {

          return {

            layer: layer.layer,





        legend = new Legend({

          map: map,

          layerInfos: layerInfo

        }, "legendWrapper");