alex92190

Clip and ship by a queried layer extent and by user defined extent

Discussion created by alex92190 on Apr 2, 2014
Latest reply on Apr 4, 2014 by alex92190
I am trying add a functionality to the clip and ship script. I would also like the users to extract data by the extent of a queried feature layer. For instance, if County = "Alameda" then extract data that falls only within the Alameda county extent. Else, allow the users to hand draw an selection area. Here is my script but my testing conditions don't work correctly. My condition test as shown below does not work properly:

//variable that calls the textbox value
    var type = document.getElementById("textbox").value;
    
    //Set up the query per type
    var queryTask = new esri.tasks.QueryTask("http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/Incident_Data_Extraction/MapServer/2");  
    var query = new esri.tasks.Query();
    query.returnGeometry = true;
    
    //field to query
    query.outFields = ["ftype"]; 
    
    //execute query
    function executeQueryTask(type) {
    query.where = "ftype = " + type; 
    
    //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 AOI = featureSet.features[0].geometry.toJSON(); 
    });
    }
    
    
    //First Area of interest selected by the client
    var Area = new FeatureSet();
    var features = [];
    features.push(map.graphics.graphics[0]);
    Area.features = features;

    if (executeQueryTask) {
     var params = {
     "Layers_to_Clip": clipLayers,
     "Area_of_Interest": AOI,
     "Feature_Format": registry.byId("formatBox").get("value")
    };
    }
    else {
     var params = {
     "Layers_to_Clip": clipLayers,
     "Area_of_Interest": Area,
     "Feature_Format": registry.byId("formatBox").get("value")
    };
    }

Outcomes