AnsweredAssumed Answered

Stuck on getting getResultImageLayer

Question asked by SHarihar-esristaff Employee on Oct 24, 2012
Latest reply on Nov 29, 2012 by SHarihar-esristaff
I am getting back the success from the GP Tool but for some reason, when I execute the,

gp.getResultImageLayer(jobInfo.jobId,"final_shp", imageParams, function(gpLayer) {    map.addLayer(gpLayer);     });


I am receiving an error on the map.addLayer(gpLayer). The error is,

Network Error: 500 Internal Server Error - <complete path of the job directory where the final.shp is created>. What is causing the layer not to be added to the Map? This is the link.

This is my code,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>          <head>         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />         <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />         <!--The viewport meta tag is used to improve the presentation and behavior         of the samples on iOS devices-->         <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"         />         <title>GP Viewshed Task</title>         <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/dojo/dijit/themes/claro/claro.css">         <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css"         />         <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2compact"></script>         <script type="text/javascript">             dojo.require("esri.map");             dojo.require("esri.tasks.gp");             dojo.require("esri.layers.FeatureLayer");             dojo.require("esri.dijit.Popup");             dojo.require("dijit.TooltipDialog");              var map, gp, featureLayer, dialog;              /*Initialize map, GP*/             function init() {                 var startExtent = new esri.geometry.Extent({                     "xmin": -13644840.338547781,                     "ymin": 4529944.368315823,                     "xmax": -13614265.527233753,                     "ymax": 4552875.476801345,                     "spatialReference": {                         "wkid": 102100                     }                 });                  map = new esri.Map("mapDiv", {                     extent: startExtent                 });                 var streetMap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");                 map.addLayer(streetMap);                 //http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons (Drive Time Polygons)                 gp = new esri.tasks.Geoprocessor("http://webgis.arizona.edu/ArcGIS/rest/services/webGIS/Shock_Models/GPServer/Income_Log");                  gp.setOutputSpatialReference({                     wkid: 102100                 });                 dojo.connect(map, "onClick", computeViewShed);                 }              function computeViewShed(evt) {                 map.graphics.clear();                 if (map.graphicsLayerIds.length >= 1) {                     map.removeLayer(map.getLayer(map.graphicsLayerIds[0]));                 }                 var pointSymbol = new esri.symbol.SimpleMarkerSymbol();                 pointSymbol.setSize(20);                 pointSymbol.setOutline(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 0]), 1));                 pointSymbol.setColor(new dojo.Color([0, 0, 255, 0.25]));                  var graphic = new esri.Graphic(evt.mapPoint, pointSymbol);                 map.graphics.add(graphic);                  var features = [];                 features.push(graphic);                 var featureSet = new esri.tasks.FeatureSet();                 featureSet.features = features;                 var params = {                     "Input_Feature_Layer": featureSet,                     "Expression": "50"                 };                 //gp.execute(params, drawViewshed);                 gp.submitJob(params, completeCallback, statusCallback, function (error) {                     alert(error);                     //esri.hide(loading);                 });              }              function completeCallback(jobInfo) {                 if (jobInfo.jobStatus !== "esriJobFailed") {                     //gp.getResultData(jobInfo.jobId,"Output_Polygons", downloadFile);                     var imageParams = new esri.layers.ImageParameters();                     imageParams.imageSpatialReference = map.spatialReference;                     gp.getResultImageLayer(jobInfo.jobId, "final.shp", imageParams, function (gpLayer) {                         map.addLayer(gpLayer);                     });                 }             }               function statusCallback(jobInfo) {                 var status = jobInfo.jobStatus;                 if (status === "esriJobFailed") {                     alert(status);                     //esri.hide(loading);                 } else if (status === "esriJobSucceeded") {                     console.log("Success");                     //esri.hide(loading);                 }             }              dojo.addOnLoad(init);         </script>     </head>          <body class="claro">         <div id="mapDiv" style="width:800px; height:600px; border:1px solid #000;"></div>Click on map to execute my GP Task.</body>  </html>

Outcomes