Solved! Go to Solution.
"http://www.myservice.com/ArcGIS/rest/services/Folder/Service/MapServer/LayerID/query?&geometry=" + geometryString + "&geometryType=esriGeometryPolygon&spatialRel=esriSpatialRelIntersects&where=" + whereClause + "&returnCountOnly=false&returnIdsOnly=false&returnGeometry=true&outFields=*&f=pjson"
dojo.require("dojo.DeferredList");
var defers = []; dojo.forEach(arrayOfBufferedGeoms, function (bufferedGeom) { var query = new esri.tasks.Query(); query.geometry = bufferedGeom; query.outSpatialReference = map.spatialReference; var queryTask = new esri.tasks.QueryTask(somelayerUrl); defers.push(queryTask.execute(query)); })); var dl = new dojo.DeferredList(defers); dojo.when(dl, function (results) { dojo.forEach(results, function(result) { //process your returned items. }); });
function DoBuffer(bufferDistance) { //Selects the buffer unit based on user input var bufferUnit = selectbufferUnit.value; switch (bufferUnit) { case 'Feet': bufferUnit = [esri.tasks.GeometryService.UNIT_FOOT]; break; case 'Miles': bufferUnit = [esri.tasks.GeometryService.UNIT_STATUTE_MILE]; break; case 'Meters': bufferUnit = [esri.tasks.GeometryService.UNIT_METER]; break; case 'Kilometers': bufferUnit = [esri.tasks.GeometryService.UNIT_KILOMETER]; break; } var params = new esri.tasks.BufferParameters(); //Sets the buffer distance based on user input params.distances = [bufferDistance]; params.unit = [bufferUnit]; params.bufferSpatialReference = map.spatialReference; params.outSpatialReference = map.spatialReference; //Gets the geometries for all the selected sites params.geometries = esri.getGeometries(map.graphics.graphics); //This parameter unions all the generated buffer polygons into a single multipart polygon params.unionResults = true; geometryService.buffer(params, ShowBuffer); features = []; } //function for Displaying the buffer function ShowBuffer(geometries) { //Creates the symbol for the buffer var lineColor = new dojo.Color(); lineColor.setColor(rendererColor); var fillColor = new dojo.Color(); fillColor.setColor(rendererColor); fillColor.a = 0.15; var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, lineColor, 2), fillColor); var bufferLayer = map.getLayer(tempBufferLayer); //Adds the buffers to a graphics layer AddGraphic2(map.getLayer(tempBufferLayer), symbol, geometries[0]); //Sets the extent of the map so that the buffers are visible var bufferPolygon = bufferLayer.graphics[0]; var bufferExtent = bufferPolygon.geometry.getExtent(); var finalExtent2 = bufferExtent.expand(1.5); map.setExtent(finalExtent2); //Queries the address point layer for any points contained within the buffers var qTask = 'qTask'; qTask = new esri.tasks.QueryTask("http://servername/arcgis/rest/services/foldername/servicename/MapServer/1"); var query = new esri.tasks.Query(); query.where = "1=1"; query.geometry = geometries[0]; query.outFields = ["*"]; query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS; query.returnGeometry = true; //All addresses returned from the query are shown on the map and also shown in a datagrid. qTask.execute(query, function (featureset) { var addressGraphics = featureset.features; //Creates the symbol for all the addresses returned from the query var symbolAddress = new esri.symbol.SimpleMarkerSymbol( esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 12, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_NULL, new dojo.Color([247, 34, 101, 0.9]), 1), new dojo.Color([207, 34, 171, 0.5]) ); //Creates the attributes for the addresses that will be added to a graphics layer var attributes; var a; for (a = 0; a < addressGraphics.length; a++) { attributes = { "OBJECTID": addressGraphics.attributes["OBJECTID"], "PIN": addressGraphics.attributes["PIN"], "BUSINESSNAME": addressGraphics.attributes["BUSINESSNAME"], "OWNAME": addressGraphics.attributes["OWNAME"], "PHYADDR1": addressGraphics.attributes["PHYADDR1"] }; //Adds the addresses to a graphics layer using t....geometry, attributes); } var results = map.getLayer(select...