Hi all I am trying to export my data via the Extract Data geoporcesssing service but I am experiencing some errors. I am trying to reproduce something similar this: Download Map Graphics - GIS Blog: ArcGIS in the Cloud, Server Hosting & More | ROK Technologies . The goal is to export graphics to FGDB after you are done with drawing.
var map;
require([
"esri/InfoTemplate",
"esri/map",
"esri/layers/FeatureLayer",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/query",
"esri/toolbars/draw",
"esri/tasks/GeometryService",
"esri/tasks/Geoprocessor",
"esri/graphic",
"esri/graphicsUtils",
"esri/tasks/FeatureSet",
"esri/geometry/Extent",
"esri/SpatialReference",
"dojo/dom",
"dojo/on",
"dojo/parser",
"dojo/_base/array",
"esri/Color",
"dojo/domReady!"
],
function (
InfoTemplate, Map, FeatureLayer, SimpleFillSymbol, SimpleLineSymbol,
Query, Draw, GeometryService, Geoprocessor, Graphic, graphicsUtils, FeatureSet, Extent,
SpatialReference, dom, on, parser, arrayUtil, Color
) {
//Parsing data
parser.parse();
//Placeholders
var selectionToolbar, featureLayer;
var extent = new esri.geometry.Extent({
"xmin": -121.11087086999999, "ymin": 38.517479534000074, "xmax": -119.95226375799996, "ymax": 39.068026806000034,
"spatialReference": { "wkid": 4326 }
});
//Map
map = new Map("map", {
basemap: "topo",
extent: extent
});
//Panel widget
var a = false;
$("#SelectWidget").click(function () {
if (!a) {
a = true;
$("#Area").show("slow", function () { });
$('#map').css("height", "80%");
}
else {
a = false;
$("#Area").hide("slow", function () { });
$('#map').css("height", "100%");
}
});
// Map on load
map.on("load", initSelectToolbar);
//My feature layer
featureLayer = new FeatureLayer("http://itas46:6080/arcgis/rest/services/Alex_test/TreeMortality/MapServer/1",
{
mode: FeatureLayer.MODE_ONDEMAND
});
featureLayer.setAutoGeneralize(false);
featureLayer.setMaxAllowableOffset(0);
//Add layer here
map.addLayer(featureLayer);
var gp = new Geoprocessor("http://itas46:6080/arcgis/rest/services/Alex_test/ExtractDataModel/GPServer/Model");
//Activate the draw tool
$("#selectFieldsButton").click(function () {
selectionToolbar.activate(Draw.EXTENT);
});
//On Map load have the Draw Toolbar ready to be activated and the union tool ready to be fired up
function initSelectToolbar(event) {
console.log("start edits");
selectionToolbar = new Draw(event.map);
var selectQuery = new Query();
var targetGeometry;
on(selectionToolbar, "DrawEnd", function (geometry) {
var geometryService = new GeometryService("http://itas46:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer");
selectQuery.geometry = geometry;
featureLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function (targetGeometry) {
targetGeometry = graphicsUtils.getGeometries(featureLayer.getSelectedFeatures());
console.log(targetGeometry);
geometryService.union(targetGeometry, function (geometry) {
featureLayer.clearSelection();
//Graphics to be shown on web map
var symbol = new SimpleFillSymbol("none", new SimpleLineSymbol("solid", new Color([255, 255, 255]), 2), new Color([255, 255, 255, 0.25]));
var graphic = new Graphic(geometry, symbol);
map.graphics.add(graphic);
//feature set
var features = [];
var fSet = new FeatureSet();
fSet.features = features;
features.push(graphic);
console.log("Test =" + fSet);
//Geoporcessing serice
var params = {
"FeaturesetGraphs": fSet,
"testAlex_zip": $("#inputlg").val()
};
gp.execute(params, getgdb);
function getgdb(result, messages) {
window.open(result[0].value.url);
}
console.log("unioned features");
}, function (err) {
console.log(err);
});
});
});
}
});
My Model:
The error I get:
My gp service looks like this:
Any idea why I am getting errors on the GP side?
Solved! Go to Solution.
found my issue was that I run an asynchronous job using "execute()" when execute is for a synchronous job.
found my issue was that I run an asynchronous job using "execute()" when execute is for a synchronous job.