alex92190

Clip and ship Query

Discussion created by alex92190 on Apr 10, 2014
Hi all, I am trying to create a web app similar to this JS API but I would like to add one functionality. I would like the users to be able to query a layer such as "County" add still be able to extract data. This is what I have so far: My script. Here are my two main functions:
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() {
var type = document.getElementById("QueryBox").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"]; 
query.where = "FMNAME_UC = type ";

queryTask.execute(query, function(featureSet){
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");
});
});
}

Outcomes