Hi!I am trying to figure out the following problem. I am using the ESRI template located here and I would like to add a simple GP tool that allows me to calculate features acres based on a "Double" field called ACRES once I finish digitizing new features (working with one polygon layer). The input value for my GPtool is the feature service layer I am using to digitize (that has an "ACRES" field). By simply adding the GPtool to the script my feature service disappears from the template picker legend. I am not sure why?? here is the code. I made sure to add thefunction: "Geoprocessor" and the dojo require: "esri/tasks/Geoprocessor" at the beginning.Thank you for your help,Alex
parser.parse();
// snapping is enabled for this sample - change the tooltip to reflect this
jsapiBundle.toolbars.draw.start = jsapiBundle.toolbars.draw.start + "<br>Press <b>ALT</b> to enable snapping";
// refer to "Using the Proxy Page" for more information: https://developers.arcgis.com/en/javascript/jshelp/ags_proxy.html
esriConfig.defaults.io.proxyUrl = "/proxy";
//This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications.
esriConfig.defaults.geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
map = new Map("map", {
basemap: "satellite",
center: [-96.541, 38.351],
zoom: 14,
slider: false
});
map.on("layers-add-result", initEditor);
//add boundaries and place names
var polygons = new FeatureLayer("http://webgisdevint1/arcgis/rest/services/Alex_Try/ACRES/FeatureServer/0",{
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ['*']
});
//Calling out the GP calculate field acreage
var gpURL = "http://webgisdevint1/arcgis/rest/services/Alex_Try/Tool/GPServer/Calculate_Acres";
var gp = new Geoprocessor(gpUrl);
function executeGP(){
var params = { "Acres":polygons};
gp.execute(params, displayTrack);
}
//Returns value
function displayTrack(results, messages) {
var polygons = results[0].value.features;
}
map.addLayers([waterbodies,rivers]);
function initEditor(evt) {
var templateLayers = arrayUtils.map(evt.layers, function(result){
return result.layer;
});
var templatePicker = new TemplatePicker({
featureLayers: templateLayers,
grouping: true,
rows: "auto",
columns: 3
}, "templateDiv");
templatePicker.startup();
var layers = arrayUtils.map(evt.layers, function(result) {
return { featureLayer: result.layer };
});
var settings = {
map: map,
templatePicker: templatePicker,
layerInfos: layers,
toolbarVisible: true,
createOptions: {
polylineDrawTools:[ Editor.CREATE_TOOL_FREEHAND_POLYLINE ],
polygonDrawTools: [ Editor.CREATE_TOOL_FREEHAND_POLYGON,
Editor.CREATE_TOOL_CIRCLE,
Editor.CREATE_TOOL_TRIANGLE,
Editor.CREATE_TOOL_RECTANGLE
]
},
toolbarOptions: {
reshapeVisible: true
}
};
var params = {settings: settings};
var myEditor = new Editor(params,'editorDiv');
//define snapping options
var symbol = new SimpleMarkerSymbol(
SimpleMarkerSymbol.STYLE_CROSS,
15,
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color([255, 0, 0, 0.5]),
5
),
null
);
map.enableSnapping({
snapPointSymbol: symbol,
tolerance: 20,
snapKey: keys.ALT
});
myEditor.startup();
}
});[ATTACH=CONFIG]31678[/ATTACH]