Select to view content in your preferred language

querytask does not always return all the features it should

594
1
Jump to solution
04-03-2012 11:55 AM
TracySchloss
Honored Contributor
I have a an application that will let the user make a few selections for a menu and based on their choices runs a querytask generates a cholorpleth map.  Because it's dynamic, the querytask and query are both created dynamically within actionscript.

This function handles the users selection:

protected function btn_loadMap_clickHandler(event:MouseEvent):void {                 if (categoryList.selectedIndex > -1 ) {  //must have selected something from the dropdownlist       category = categoryList.selectedItem.data;      }       if ( mapList.selectedIndex > -1) {       mapChoice = mapList.selectedItem.data;      }       if (!category || !mapChoice) {       Alert.show("Please select both a chemical use and map type.", "Need Selections to Generate Map");      }           yearValue = radio_yearButtons.selectedValue;       if (categoryList.selectedIndex > -1 && mapList.selectedIndex > -1) {             classBreakField = category + "_" + yearValue + "_" + mapChoice;        mapTitle.text = yearValue + " - " + categoryArrayObj[category] + ", " + mapTopicArrayObj[mapChoice];        lblLegend.text = mapTopicArrayObj[mapChoice] + " - " + yearValue;            qryTask_selectedField();      }    }


Once the selection has been made, the function qryTask_selectedField is called and it creates and executes the query and querytask.  This is county based data and all counties should be returned from the query.  All fields have some data value in

  
private function qryTask_selectedField ():void  {      trace ("in qrytask_selectedField function");     graphicsLayer.clear();     mainMap.infoWindow.hide();     var coQryTask:QueryTask = new QueryTask ();      coQryTask.showBusyCursor = true;     coQuery.geometry = mainMap.extent;     coQryTask.useAMF=false;     coQryTask.url = "http://" + localpathName + "/arcgis/rest/services/EPHT_AgChemical_county/MapServer/0"     coQryTask.addEventListener(QueryEvent.EXECUTE_COMPLETE, coResult);     coQryTask.addEventListener(FaultEvent.FAULT, onFault);     coQryTask.execute(coQuery);     //coQryTask.execute(coQuery, new AsyncResponder( coResult, onFault ));            }


You can see I started out with an asyncResponder, which I've always used for my querytasks.  It worked just great for me every time.  The problem is that my test users have not always seeing all the counties shaded in.    I changed it around to have listeners on the QueryEvent for EXECUTE_COMPLETE and for the fault.  Maybe I'm not correct yet in my syntax.  It still works for me and it still doesn't work for my users!

In order to see if the number of features was being returns correctly and not just some random color problem from my dynamic class renderer. I put a small label at the bottom of my map.  It is set as:

<s:Label id="lbl_featureCount" text="Number of features from query:" fontStyle="italic" />


I populate this with the number of features in the featureset.  The query should always return 115 features (the number of counties in Missouri).  Users have randomly been getting 105, 107, 111 and sometimes all 115.  I feel like the query task isn't fully complete before it sets the graphicLayer.graphicProvider, but it's just so random!  I thought the queryEvent executecomplete event would take care of it.

I will add that these users are actually on the same campus as our AGS server and I'm in another part of town!  The coResult function is quite complex.  If anyone thinks seeing it will help, I can post as an attachment in a reply.  I doubt it will fit in this dialog box!  As you can see with my AMF=false, my AGS server is still at version 9.3.  Maybe some day we'll be ready to upgrade!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
TracySchloss
Honored Contributor
I'm answering my own question, but I wanted to post what I hope is the final resolution:


I'm not sure why I had an extent set on the query.  Somewhere along the line I thought I needed it.  I guess for the end users with their different screen sizes and resolutions the extent I'd defined at the start didn't work for them.  The map drew OK, but the query was cutting off the counties along the borders.  Once I removed
coQuery.geometry = mainMap.extent;
all was well.

View solution in original post

0 Kudos
1 Reply
TracySchloss
Honored Contributor
I'm answering my own question, but I wanted to post what I hope is the final resolution:


I'm not sure why I had an extent set on the query.  Somewhere along the line I thought I needed it.  I guess for the end users with their different screen sizes and resolutions the extent I'd defined at the start didn't work for them.  The map drew OK, but the query was cutting off the counties along the borders.  Once I removed
coQuery.geometry = mainMap.extent;
all was well.
0 Kudos