Last active
April 26, 2019 21:54
-
-
Save nommuna2/117a6fe1efb03737b2cdcfe9a4724cb7 to your computer and use it in GitHub Desktop.
(ArcGIS API for JavaScript) Sample of passing a feature set to a GPService (Event driven)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(["esri/map", | |
"esri/layers/FeatureLayer", | |
"esri/tasks/QueryTask", | |
"esri/tasks/query", | |
"esri/tasks/Geoprocessor", | |
"dojo/domReady!" | |
], function (Map, FeatureLayer, QueryTask, Query, Geoprocessor) { | |
//Initializing the map constructor | |
var map = new Map("map", { | |
center: [-118, 34.5], | |
zoom: 4, | |
basemap: "topo" | |
}); | |
var layer = new FeatureLayer("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2"); | |
var url = "path to gp service"; | |
var query = new Query(); | |
query.returnGeometry = true; | |
//query.where = "state_name = 'California'"; | |
query.where = "1=1"; | |
query.outFields = ["*"]; | |
var queryTask = new QueryTask("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2"); | |
queryTask.execute(query); | |
queryTask.on("complete", (result) => { | |
console.log(result); | |
executeTask(result.featureSet); //Passing in just result works as well | |
}); | |
function executeTask(featuresSet) { | |
console.log(featuresSet); | |
var params = { | |
//"Layers_to_Clip": "", | |
"Area_of_Interest": featuresSet | |
}; | |
var gpService = new Geoprocessor(url); | |
gpService.execute(params, (e) => { | |
alert(e[0].value.url); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment