Select to view content in your preferred language

Select by buffer running multiple times on subsequent calls

834
1
11-14-2011 11:03 AM
GarethMann
Deactivated User
I am working on a page that allows a user to search out an address and get demographic data about the surrounding area. The process is simply:

geocode->buffer->query layer 1 by buffer->select and query layer 2 by same buffer.


There are 2 relevant data layers in the GIS Service that it pulls from:

1) 2000 Census Tracts with ACS 05-09 data This shows older census tracts boundaries and is turned off in the service so users cannot actually see the boundaries. I am using the simple query by buffer code that i found here to pull the data from this layer:
http://help.arcgis.com/en/webapi/javascript/arcgis/demos/query/query_buffer.html

1) 2010 Census Tracts  This shows the latest census tracts. This layer is turned on and because I need the user to see which census tracts from this layer were included in the analysis, I am selecting (rather than simply querying) the features from this layer using the buffer.

Here is the page and the code:
http://northmiamicra.org/marketanalysis.html

For some reason, the first query rarely gets called (about 1 in 4 times), whereas the selection query on the second layer gets called the same number of times that the button on the page is pressed since the last page refresh. So when you press the button that says "find address", it will output the results of the request once. But then if you hit the button again, it will run the query twice and output the results twice. If you hit the button a third time it will run it 3 times and output the results 3 times, and so on....

So I wanted to find out the following:

1) Why is the first query almost never getting completed?

2) Why does the second query get run multiple times on second and third requests? (I have tried to be careful to empty out my variables and clear the map graphics before running the request a second time).
0 Kudos
1 Reply
GarethMann
Deactivated User
OK, I have fixed the first problem. It was due to the fact that the secon query was getting completed before the first one so the string storing the values was still empty when the second query was completed. So I moved the function that fires the second query to within the trigger for the completion of the first query, which seems to have fixed the problem:

http://northmiamicra.org/marketanalysis2.html

However, the second error I have not yet found a solution for. In fact, since I modified the code to fix the first error, the second error is manifesting itself even stranger. Now when I press the "find address" button a second time, it runs the second query a total of 7 times! Why an earth is it doing this?
0 Kudos