AnsweredAssumed Answered

Automatically zoom out when no filtered features available in current extent

Question asked by schlot on Oct 6, 2015
Latest reply on Oct 7, 2015 by schlot

I have a featureLayer with a couple of dropdowns that define a filterExpression on the layer.  These are types of medical providers and for some specialty areas there aren't many specialists across the whole state.

 

I have a grid tied to the map, which lists out the features in the current map extent. Once a user has zoomed in, if they then change their filter to a specialty that isn't very common, there are no features displayed on the map, and the provider grid has a message that suggests they zoom out or change their filter to see some results.

 

I'd like to help the user out more than this, by having the map automatically zoom out until there is at least one filtered features shown. I can't figure out how to do this without iteratively zooming out, checking if there are features yet, zooming out again, etc.

 

Is there a less clunky process?  If that's the own solution, does anyone have a code snippet to share?

Outcomes