Thanks Heming. I applied your code to my js file. I think everything is good above the start of function extractData(). Nothing happens when I use Chrome to click the "Extract" button. At least IE gave the following error:
Message: 'spatialReference.wkid' is null or not an object
Line: 48
Char: 427431
Code: 0
URI: http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.6
Boy, this is going to ruin my new year's eve weekend 😞
Question: for the line that reads "var outSR = new esri.SpatialReference ( { wkid : 2236});" does wkid need to be quoted so it is written ad "wkid"?
Thanks again for your help. I'll do some research over the weekend while following the path you set out. At the same time, if something jumps out at you I would appreciate feedback. Here is my code at the moment:
dojo.require("dijit.dijit"); // optimize: load dijit layer dojo.require("dijit.layout.BorderContainer"); dojo.require("dojox.layout.FloatingPane"); dojo.require("dijit.layout.ContentPane"); dojo.require("dijit.form.CheckBox"); dojo.require("dijit.form.ComboBox"); dojo.require("esri.map"); dojo.require("esri.dijit.Popup"); dojo.require("esri.geometry"); /*------------------------------------*/ // GLOBAL VARIABLES /*-----------------------------------*/ var gp, map; var loading; var selectionToolbar; //hzhu added var gsvc; function init() { //configure map zoom animation to be slower (Gives a cool effect, almost similar to the Flex Viewer zoom) //The default for zoomDuration in milliseconds is 250 //Default for zoomRate is 25 esri.config.defaults.map.zoomDuration = 1000; esri.config.defaults.map.zoomRate = 50; //configure map pan animation to be slower //time in milliseconds; default panDuration:250 //refresh rate of zoom animation; default panRate:25 esri.config.defaults.map.panDuration = 1000; esri.config.defaults.map.panRate = 50; //esri.config.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx"; esri.config.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx"; loading = dojo.byId("loadingImg"); var initialExtent = new esri.geometry.Extent({"xmin":-8931399.85128929,"ymin":3006918.03708705,"xmax":-8913140.86444157,"ymax":3026297.04737907,"spatialReference":{"wkid":102100}}); map = new esri.Map("map", { extent: initialExtent }); dojo.connect(map, 'onLoad', function(map) { initSelectionToolbar(); //resize the map when the browser resizes dojo.connect(dijit.byId('map'), 'resize', map, map.resize); }); var basemapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"; var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl); map.addLayer(basemap); //var FortLaudMapLayers = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtractionDownloads/MapServer"); var FortLaudMapLayers = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtraction/MapServer"); map.addLayer(FortLaudMapLayers); //hzhu added gsvc = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); //gp = new esri.tasks.Geoprocessor("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtractionDownloads/GPServer/Extract%20Data%20Task"); gp = new esri.tasks.Geoprocessor("http://gis.fortlauderdale.gov/ArcGIS/rest/services/AppsITS/DataExtraction/GPServer/Extract%20Data%20Task"); } function initSelectionToolbar(myMap) { selectionToolbar = new esri.toolbars.Draw(map); dojo.connect(selectionToolbar, "onDrawEnd", function(geometry) { selectionToolbar.deactivate(); var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25])); var graphic = new esri.Graphic(geometry, symbol); map.graphics.add(graphic); }); } function activateTool(type) { selectionToolbar.activate(); } function extractData() { //hzhu added var outSR = new esri.SpatialReference({ wkid : 2236 }); //hzhu added gsvc.project([map.graphics.graphics[0]], outSR, function(graphics) { //hzhu added var graphic = graphics[0]; //get clip layers var clipLayers = []; if(dijit.byId('layer0').checked) { clipLayers.push('Bridges (Moveable)'); } if(dijit.byId('layer1').checked) { clipLayers.push('Building Permits'); } if(dijit.byId('layer2').checked) { clipLayers.push('Businesses'); } if(dijit.byId('layer3').checked) { clipLayers.push('Fire Stations'); } if(dijit.byId('layer4').checked) { clipLayers.push('Lifeguard Towers'); } if(dijit.byId('layer5').checked) { clipLayers.push('Ocean Buoys'); } if(dijit.byId('layer6').checked) { clipLayers.push('Section Points (Florida PLSS)'); } if(dijit.byId('layer7').checked) { clipLayers.push('Survey Benchmarks'); } if(dijit.byId('layer8').checked) { clipLayers.push('City Limits (Fort Lauderdale)'); } //hzhu modified if(clipLayers.length === 0 || graphics.length === 0) { alert('Select layers to extract and area of interest'); return; } var features = []; features.push(graphic); var featureSet = new esri.tasks.FeatureSet(); featureSet.features = features; var params = { "Layers_to_Clip" : clipLayers, "Area_of_Interest" : featureSet, "Feature_Format" : dijit.byId('formatBox').value } esri.show(loading); gp.submitJob(params, completeCallback, statusCallback, function(error) { alert(error); esri.hide(loading); }); }); } function completeCallback(jobInfo) { if(jobInfo.jobStatus !== "esriJobFailed") { gp.getResultData(jobInfo.jobId, "Output_Zip_File", downloadFile); } } function statusCallback(jobInfo) { var status = jobInfo.jobStatus; if(status === "esriJobFailed") { alert(status); esri.hide(loading); } else if(status === "esriJobSucceeded") { esri.hide(loading); } } function downloadFile(outputFile) { map.graphics.clear(); var theurl = outputFile.value.url; window.location = theurl; } //show map on load dojo.addOnLoad(init);
this format actually works. it may be something else. I too am having problems creating the clip and ship site. I can manually enter the parameters through the REST interface. Your 'Area of Interest' syntax format works for me. Do you have it working?
just tried your site and received a job failed message.
If you get a chance try it again. I restarted the geoprocessing service and the mapservice. That action apparently did the trick. I'm not sure why I had to do that because it has been working fine for about 2 months now. Maybe the services experience issues every so often. Nonetheless, thanks for notifying me.
Where do I put the workaround you sent? I am using the sample clip and ship from Esri's site. Thanks in advance.
function extractData() { //get clip layers var clipLayers = []; if(dijit.byId('layer0').checked) { clipLayers.push('Bridges (Moveable)'); } if(dijit.byId('layer1').checked) { clipLayers.push('Building Permits'); } if(dijit.byId('layer2').checked) { clipLayers.push('Businesses'); } if(dijit.byId('layer3').checked) { clipLayers.push('Colleges and Universities'); } if(dijit.byId('layer4').checked) { clipLayers.push('Fire Stations'); } if(clipLayers.length === 0 || map.graphics.graphics.length === 0) { alert('Select layers to extract and area of interest'); return; } var features = []; features.push(map.graphics.graphics[0]); var featureSet = new esri.tasks.FeatureSet(); featureSet.features = features; var params = { "Layers_to_Clip" : clipLayers, "Area_of_Interest" : featureSet, "Feature_Format" : dijit.byId('formatBox').value } esri.show(loading); gp.submitJob(params, completeCallback, statusCallback, function(error) { alert(error); esri.hide(loading); }); } function completeCallback(jobInfo) { if(jobInfo.jobStatus !== "esriJobFailed") { gp.getResultData(jobInfo.jobId, "Output_Zip_File", downloadFile); } } function statusCallback(jobInfo) { var status = jobInfo.jobStatus; if(status === "esriJobFailed") { alert(status); esri.hide(loading); } else if(status === "esriJobSucceeded") { esri.hide(loading); } } function downloadFile(outputFile) { map.graphics.clear(); var theurl = outputFile.value.url; window.location = theurl; } /*--------------------------------------------------------------------------*/ /* +++++ THIS BLOCK CONTAINS THE WORK AROUND CODE ++++++++*/ esri.setRequestPreCallback(function(ioargs) { if(ioargs.content.Area_of_Interest) { var aoijson = dojo.fromJson(ioargs.content.Area_of_Interest); aoijson.spatialReference = aoijson.sr; ioargs.content.Area_of_Interest = dojo.toJson(aoijson); console.log('test'); } return ioargs; }); /* +++++ END OF WORK AROUND CODE ++++++++++++++++++++++++++ */ //------------------------------------------------- function showLoading() { esri.show(loading); map.disableMapNavigation(); map.hideZoomSlider(); } function hideLoading(error) { esri.hide(loading); map.enableMapNavigation(); map.showZoomSlider(); } //----------------------------------------------- dojo.addOnLoad(init);