Hi I'm using ArcGIS JS API 3.21 and Web Appbuilder for Developers 2.7.
I'm defining and adding a feature layer from a map service to my map, giving it a custom unique value renderer and setting a definition expression and it is working fine. The final thing I need to do is to filter it by a custom polygon geometry. In the service you can pass custom geometry to a query, I just need to find out how to set a filter on my feature layer using the same geometry.
I've tried using MODE_SELECTION and then selecting features with the geometry, but this gets rid of my unique value renderer in favour of the selection symbol. I'm pretty sure I can't set a unique value renderer as the selection symbol and even then that would be a bit hacky.
The user needs to generate a custom selection of features from the map using attribute filtering and custom polygon filtering, and once they are happy with their selection the features are submitted via a HTTP request to an ordering system. The user only wants their currently selected features to appear on the map.
Something like this would be good:
The featurelayer definition expression and input geometry can be updated on the fly as the user interacts with the widget.
Any suggestions would be appreciated.
Your workflow should be do a queryIds on the FeatureLayer to get the ids that the geometry intersect with and then use the FeatureLayers setDefinitionExpression using a sql statement like ObjectID IN (your results from the Ids query array.join()).
Thanks for getting back to me. The feature layer that they are doing their selection on has many thousands of features that are densely packed. Is there a limit to the length of the definition expression that I can use, as the number of selected features have the potential to be quite large.
That is exactly the situation that the SQL Syntax ObjectID IN (x,y,z) is capable of handling.