//This is the query using the point tool to select the counties [Bindable] private var queryTaskcounty:QueryTask = new QueryTask(); [Bindable] private var querycounty:Query = new Query(); //this is the query using the point tool to select the companies inside the counties selected [Bindable] private var queryTaskcompanyincounty:QueryTask = new QueryTask(); [Bindable] private var querycompanyincounty:Query = new Query(); private function runQueryTaskcounty(geometry:Geometry):void { queryTaskcounty.url = "http://tfs-24279/ArcGIS/rest/services/ForestProducts/county_forest_products/MapServer/0"; queryTaskcounty.showBusyCursor = true; queryTaskcounty.useAMF = false; querycounty.geometry = geometry; //geometry from the drawToolbar querycounty.returnGeometry = true; //set to true because we want to place points on the map querycounty.spatialRelationship = "esriSpatialRelIntersects"; querycounty.outSpatialReference = myMap.spatialReference; querycounty.outFields = ['*']; //run the query task queryTaskcounty.execute(querycounty, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { myGraphicslayer.clear() myGraphicslayer.visible = true; for each(var graphic : Graphic in featureSet.features) { graphic.symbol = fillSymbolmultipoint; myGraphicslayer.add(graphic); //Now run this query //Of course this url needs to be to the layer that has your companies queryTaskcompanyincounty.url = "http://tfs-24279/ArcGIS/rest/services/ForestProducts/dynamic_layer_forest_products/MapServer/0"; queryTaskcompanyincounty.showBusyCursor = true; queryTaskcompanyincounty.useAMF = false; querycompanyincounty.geometry = graphic.geometry; //geometry from the first query querycompanyincounty.returnGeometry = true; //set to true because we want to place points on the map querycompanyincounty.spatialRelationship = "esriSpatialRelIntersects"; querycompanyincounty.outSpatialReference = myMap.spatialReference; querycompanyincounty.outFields = ['*']; //run the query task queryTaskcompanyincounty.execute(querycompanyincounty, new AsyncResponder(onResultcompanyincounty, onFault)); } } function onResultcompanyincounty(featureSet:FeatureSet, token:Object = null):void { //myGraphicslayer.clear() myGraphicslayer.visible = true; resizableDraggableTitleWindowcompanyincounty.visible = true; querydgcompanyincounty.visible = true; //querydgcompanyincounty.dataProvider = queryTaskcompanyincounty.executeLastResult.attributes // to deselect the zooming tools when the graphic layers appear tbb.selectedIndex = -1 var countyName:String = new String; var tempArray:Array = new Array(); var featuresInSelect:int = 0 for each(var graphic:Graphic in featureSet.features){ graphic.symbol = resultsSymbol; myGraphicsLayer.add(graphic); var Companyv:String = graphic.attributes['Company']; countyName = graphic.attributes['County']; featuresInSelect++; //set up array so that this data can be sent to the datagrid tempArray.push( { Name:countyName, Company:Companyv } ); } //populate the datagrid, querydgcompanyincounty.dataProvider = tempArray; if (myGraphicsLayer.numGraphics == 0) { info.text = "There are no records"; } if (myGraphicsLayer.numGraphics > 1) { info.text = " There are" + myGraphicsLayer.numGraphics + " matching records"; } if (myGraphicsLayer.numGraphics == 1) { info.text = " There is" + myGraphicsLayer.numGraphics + " matching record"; } } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString(), "Query Problem"); } }
Solved! Go to Solution.
function onResultcompanyincounty(featureSet:FeatureSet, token:Object = null):void { //myGraphicslayer.clear() myGraphicslayercounty.visible = true; resizableDraggableTitleWindowcompanyincounty.visible = true; querydgcompanyincounty.visible = true; //querydgcompanyincounty.dataProvider = queryTaskcompanyincounty.executeLastResult.attributes // to deselect the zooming tools when the graphic layers appear tbb.selectedIndex = -1 //Alert.show(featureSet.features.length.toString()) for each(var graphic : Graphic in featureSet.features){ graphic.symbol = resultsSymbol; myGraphicsLayer.add(graphic); // added these 3 next lines to make all the records appear in the datagrid, I had to use the graphics as source as the featureset just shows part of the results //Because all the first county selected will immediattely get a point, then the second one and so forth, like there are two queries, the first and second queries //occur concurrently for the county selected. var featureset:FeatureSet; featureset = new FeatureSet(ArrayCollection(myGraphicsLayer.graphicProvider).toArray()); querydgcompanyincounty.dataProvider = featureset.attributes; graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOvercompanyincounty); graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutcompanyincounty); } if (myGraphicsLayer.numGraphics == 0) { info.text = "There are no records"; } if (myGraphicsLayer.numGraphics > 1) { info.text = " There are" + myGraphicsLayer.numGraphics + " matching records"; } if (myGraphicsLayer.numGraphics == 1) { info.text = " There is" + myGraphicsLayer.numGraphics + " matching record"; } } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString(), "Query Problem"); } }
function onResultcompanyincounty(featureSet:FeatureSet, token:Object = null):void { //myGraphicslayer.clear() myGraphicslayer.visible = true; resizableDraggableTitleWindowcompanyincounty.visible = true; querydgcompanyincounty.visible = true; querydgcompanyincounty.dataProvider = queryTaskcompanyincounty.executeLastResult.attributes // to deselect the zooming tools when the graphic layers appear tbb.selectedIndex = -1 Alert.show(featureSet.features.length.toString()) for each(var graphic : Graphic in featureSet.features){ graphic.symbol = resultsSymbol; myGraphicsLayer.add(graphic); } if (myGraphicsLayer.numGraphics == 0) { info.text = "There are no records"; } if (myGraphicsLayer.numGraphics > 1) { info.text = " There are" + myGraphicsLayer.numGraphics + " matching records"; } if (myGraphicsLayer.numGraphics == 1) { info.text = " There is" + myGraphicsLayer.numGraphics + " matching record"; } } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString(), "Query Problem"); } }
function onResultcompanyincounty(featureSet:FeatureSet, token:Object = null):void { //myGraphicslayer.clear() myGraphicslayercounty.visible = true; resizableDraggableTitleWindowcompanyincounty.visible = true; querydgcompanyincounty.visible = true; //querydgcompanyincounty.dataProvider = queryTaskcompanyincounty.executeLastResult.attributes // to deselect the zooming tools when the graphic layers appear tbb.selectedIndex = -1 //Alert.show(featureSet.features.length.toString()) for each(var graphic : Graphic in featureSet.features){ graphic.symbol = resultsSymbol; myGraphicsLayer.add(graphic); // added these 3 next lines to make all the records appear in the datagrid, I had to use the graphics as source as the featureset just shows part of the results //Because all the first county selected will immediattely get a point, then the second one and so forth, like there are two queries, the first and second queries //occur concurrently for the county selected. var featureset:FeatureSet; featureset = new FeatureSet(ArrayCollection(myGraphicsLayer.graphicProvider).toArray()); querydgcompanyincounty.dataProvider = featureset.attributes; graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOvercompanyincounty); graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutcompanyincounty); } if (myGraphicsLayer.numGraphics == 0) { info.text = "There are no records"; } if (myGraphicsLayer.numGraphics > 1) { info.text = " There are" + myGraphicsLayer.numGraphics + " matching records"; } if (myGraphicsLayer.numGraphics == 1) { info.text = " There is" + myGraphicsLayer.numGraphics + " matching record"; } } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString(), "Query Problem"); } }