AnsweredAssumed Answered

Zoom to geoprocessor result

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

Hi,

   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.

Thanks,

-dave

 

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);

    layer.id = "Created Mammal Data";

    map.addLayers([layer]);

  });

 

  // 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) {

    domUtils.show(dom.byId('legendWrapper'));

      if (!legend) {

        var layerInfo = array.map(evtObj.layers, function (layer, index) {

          return {

            layer: layer.layer,

            title: layer.layer.name

          };

        });

       

        legend = new Legend({

          map: map,

          layerInfos: layerInfo

        }, "legendWrapper");

        legend.startup();

      }

    });

  }

Outcomes