Spatial condition in FeatureLayer.definitionExpression?

316
3
04-03-2020 08:25 AM
MassimilianoSantini
New Contributor

Hi,

is there a way to set a spatial condition in FeatureLayer.definitionExpression?

I mean select and show features inside a geometry object.

My FeatureLayer is a huge layer server side.

Thanks

Massimiliano

0 Kudos
3 Replies
AnneFitz
Esri Contributor

Hi Massimiliano,

Instead of using definitionExpression, try using FeatureLayer.queryFeatures(). See this section in the API Reference on Spatial Queries for more information: Spatial Query | ArcGIS API for JavaScript 4.14 

Here's a sample that shows querying statistics by geometry: SceneLayerView - query statistics by geometry | ArcGIS API for JavaScript 4.14 

Hope this helps! 

Thanks,

Anne

MassimilianoSantini
New Contributor

Hi Anne,

and so I did but I wanted to avoid creating a new client side layer.

However I used QueryTask to perform the spatial selection, is it the same in terms of performance as FeatureLayer.queryFeatures() ?

thank you

Massimiliano

0 Kudos
AnneFitz
Esri Contributor

Yes, they are the same in terms of performance, assuming that your FeatureLayer is created from a service. But it is probably better to just use FeatureLayer.queryFeatures() so that you do not have to import another task.