AnsweredAssumed Answered

Can I filter a FeatureLayer by a custom geometry

Question asked by on Mar 28, 2018
Latest reply on Mar 29, 2018 by rscheitlin

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:

var featureLayer = new FeatureLayer(layerUrl, {
mode: FeatureLayer.MODE_SNAPSHOT,
outFields: [field],
id: OverLayerID,
showAttribution: false
featureLayer.setInputGeometry(geometry); <------  something like this would be perfect;


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.