It's quite a long code to go through, can you be specific what "not working" means? You can monitor webrequests using Fiddler to see if there are any failure. Does map load fine? Features retrieved fine? What part of query fails? All that maybe answered when you have Fiddler on. You can also try setting breakpoints to check if your code is hit when expected.