Would like to clarify on this topic a little further. If I am interpreting the original post right, the intended approach is:
- Load all features for a FeatureLayer to the map.
- Add a definitionExpression to the FeatureLayer to filter the layer.
- Set the map extent to the extent of the filtered FeatureLayer.
- Change the definitionExpression on the FeatureLayer to filter to another feature or feature set in an area not currently in the view.
- Set the map extent to that of the updated filtered FeatureLayer.
The goal is to do this without having to query the service to get the extent of the filtered FeatureLayer. Considering the FeatureLayer is already loaded to the client, another query to the service should not be necessary. I have been experimenting with the same approach.
The docs for FeatureLayer.queryExtent() state “To query for the extent of features/graphics available to or visible in the View on the client rather than making a server-side query, you must use the FeatureLayerView.queryExtent() method.”
This would indicate that the approach above is not possible without zooming back out to the full FeatureLayer extent prior to setting the map extent the second time. Running FeatureLayer.queryExtent() will result in another query to the service. Running FeatureLayerView.queryExtent() will not query the service but it will not correctly set the map extent unless the next feature set is in the view when FeatureLayerView.queryExtent() is executed.
I did some testing, and what I am seeing indicates that running FeatureLayer.queryExtent() DOES query the service. Running FeatureLayerView.queryExtent() does not query the service.
Am I missing something?