Zoom to feature layer selection problem

1170
3
Jump to solution
09-26-2014 10:30 AM
RyanSellman
Occasional Contributor II

In the app I am working on, I allow users to select features from a feature layer, which I add using MODE_SELECTION.  I have it set to zoom to the extent of the selected graphics, upon the end the user drawn polygon.  The issue I am having is odd.  When you do the selection for the first time in the session, the features are selected, but the extent doesn't change.  If I perform another selection, it zooms to what the previous selection extent was.  If I do another selection, again it zooms to the previous selection's extent and so on.

If I add the layer using MODE_ONDEMAND, it works perfectly.  Anyone know what I am missing?  Attached is the querytask code.

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

I bet this is a deferred event issue. Try moving your map.setExtent() function inside of the feature selection callback function right above it.

View solution in original post

3 Replies
by Anonymous User
Not applicable

I bet this is a deferred event issue. Try moving your map.setExtent() function inside of the feature selection callback function right above it.

RyanSellman
Occasional Contributor II

Sarah,

That was it!  Thanks for the help!

Ryan

0 Kudos
by Anonymous User
Not applicable

Glad to hear it! It's good practice in the forums to mark a reply as the 'Correct Answer' when it solved your issue, so other folks can find solutions more easily. Have a good one!

0 Kudos