Yes!!! you are on the right track. Use GeometryService's buffer method to create buffer polygons instead. Here is doc you can look at: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/geometryservice.htm
Hi I am also trying to use the clip and ship template but is not successful. What I am trying to do is to allow the users to either clip by a user-drawn polygon graphic as shown in the ESRI example or query a county layer to clip data to the extent of certain counties. If any of you have ideas, suggestions. It is most welcome. I have been working on this for well over a week now.gp = new Geoprocessor("http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/Incident_Data_Extraction/GPServer/Extract%20Data%20Task");
gp.setOutSpatialReference({wkid:102100});
registry.byId("polygon").on("click", function() {
activateTool(this.id);
});
registry.byId("freehandpolygon").on("click", function() {
activateTool(this.id);
});
registry.byId("extract").on("click", extractData);
registry.byId("Query").on("click", executeQueryTask);
function initSelectionToolbar() {
map.graphics.clear();
selectionToolbar = new Draw(map);
selectionToolbar.on("draw-end", function(e) {
selectionToolbar.deactivate();
var symbol = new SimpleFillSymbol(
"solid",
new SimpleLineSymbol("dash", new Color([255,0,0]), 2),
new Color([255,255,0,0.25])
);
var graphic = new Graphic(e.geometry, symbol);
map.graphics.add(graphic);
});
}
function activateTool(tool) {
map.graphics.clear();
// The draw.activate expects a string like "polygon" or "freehand_polygon".
selectionToolbar.activate(tool);
}
function extractData(){
//get clip layers
var clipLayers = [];
if ( registry.byId("layer1").get("checked") ) { clipLayers.push("Incident Points"); }
if ( registry.byId("layer2").get("checked") ) { clipLayers.push("Incident Lines"); }
if ( registry.byId("layer3").get("checked") ) { clipLayers.push("Incident Areas"); }
if ( clipLayers.length === 0 || map.graphics.graphics.length === 0 ) {
alert("Select layers to extract and draw an area of interest.");
return;
}
}
function executeQueryTask() {
//variable that calls the textbox value
var type = document.getElementById("textbox").value;
var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/Alex_Try/Counties/MapServer/0"); //Your county feature service
var query = new Query();
query.returnGeometry = true;
query.outFields = ["FMNAME_UC"]; //Your county name field in your feature service
query.where = "FMNAME_UC = 'SISKIYOU COUNTY'";
//If you want a result handler function, just replace that here
queryTask.execute(query, function(featureSet){
//This is designed to get the FIRST feature graphic as a JSON in the return because I am assuming you only have one county with that name
var params = {
"Layers_to_Clip": clipLayers,
"Feature_Format": registry.byId("formatBox").get("value")
};
if (featureSet.features.length > 0) {
params.Area_of_Interest = featureSet.features[0].geometry;
} else {
params.Area_of_Interest = map.graphics.graphics[0].geometry;
}
domStyle.set(loading, "display", "inline-block");
gp.submitJob(params, completeCallback , statusCallback, function(error){
alert(error);
domStyle.set(loading, "display", "none");
});
});
}
Thank you Alex