gp.getResultImageLayer(jobInfo.jobId,"final_shp", imageParams, function(gpLayer) { map.addLayer(gpLayer); });
<!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>
Solved! Go to Solution.
if I see log with a sample request (via browser)
http://webgis.arizona.edu/ArcGIS/rest/services/webGIS/Shock_Models/GPServer/Income_Log/submitJob?Inp...
I see that output isn't in arcgisjobs but in your temp so it isn't accessible. Have you set variable stratchworkspace ? Name of Parameter output is final_shp (I see in code final.shp) and set it esriGPParameterTypeRequired.
"NetworkError: 500 Internal Server Error - http://webgis.arizona.edu/ArcGIS/rest/services/webGIS/Shock_Models/GPServer/Income_Log/jobs/jc47c82f..."
Have you details in log of rest, in event viewer windows and in iis?
Have you details in log of rest, in event viewer windows and in iis?
SESSION STATE: Done. Response Entity Size: 849 bytes. == FLAGS ================== BitFlags: [ClientPipeReused, ServerPipeReused] 0x18 X-CLIENTPORT: 2010 X-RESPONSEBODYTRANSFERLENGTH: 849 X-EGRESSPORT: 2023 X-HOSTIP: 128.196.53.161 X-PROCESSINFO: firefox:2248 X-CLIENTIP: 127.0.0.1 X-SERVERSOCKET: REUSE ServerPipe#2 == TIMING INFO ============ ClientConnected: 15:53:51.383 ClientBeginRequest: 15:53:51.494 GotRequestHeaders: 15:53:51.494 ClientDoneRequest: 15:53:51.494 Determine Gateway: 0ms DNS Lookup: 0ms TCP/IP Connect: 0ms HTTPS Handshake: 0ms ServerConnected: 15:52:45.077 FiddlerBeginRequest: 15:53:51.495 ServerGotRequest: 15:53:51.495 ServerBeginResponse: 15:53:51.679 GotResponseHeaders: 15:53:51.679 ServerDoneResponse: 15:53:51.679 ClientBeginResponse: 15:53:51.679 ClientDoneResponse: 15:53:51.679 Overall Elapsed: 00:00:00.1850106 The response was buffered before delivery to the client. == WININET CACHE INFO ============ This URL is not present in the WinINET cache.* Note: Data above shows WinINET's current cache state, not the state at the time of the request. * Note: Data above shows WinINET's Medium Integrity (non-Protected Mode) cache only.
Well I am happy for you!
If I have understand your question: see this sample http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_dialog.html
gp.getResultImageLayer(jobInfo.jobId,"final_shp", imageParams, function(gpLayer) { map.addLayer(gpLayer); });