Subset features that are displayed based on a spatial query

3799
7
05-28-2015 09:26 AM
KeithWeber1
New Contributor III

Hello,

I have a web application that provides the user with several different options to subset the visible features on the map. Most of the subset criteria is applied using a layer's definition expression. One way I would like to allow the user to subset the visible features is to allow the user to draw a polygon on the map and only the features that are within the polygon get displayed. What is the best way to achieve this behavior?

I am currently using ArcGIS Flex API and the layer type is an ArcGISDynamicMapServiceLayer.

0 Kudos
7 Replies
EvelynHernandez
Occasional Contributor III
0 Kudos
KeithWeber1
New Contributor III

Evelyn,

Thanks for the quick response! Looking at the example, it appears that it is changing the renderer of each feature based on if it falls within the extent. However, the functionality that I am looking for is basically the exact same functionality as a definition expression, meaning that only the features that match the criteria are considered to be part of the layer (displayed on the map, visible in an attribute table, etc.)

0 Kudos
KeithWeber1
New Contributor III

Evelyn,

Do you know if there is a way to include spatial criteria within a definition expression? In my case, I have line features and want to show all line features that are fully contained within a polygon.

0 Kudos
EvelynHernandez
Occasional Contributor III

Maybe u can make a mix with this and the other link that i just showed u, adding the extent based on user interaction.

Find features in Map Layers—ArcGIS API for Flex | ArcGIS for Developers

0 Kudos
KeithWeber1
New Contributor III

Evelyn,

Thanks! I'll check it out and see if I can get it working. I appreciate your suggestions very much!

0 Kudos
KeithWeber1
New Contributor III

After just a little more digging, it looks like this is what I am looking for

https://developers.arcgis.com/flex/sample-code/query-result-on-map.htm

It sets the graphicProvider to the results of the query and I think I can put both spatial and attribute criteria in a single query. Thanks again, Evelyn! I wouldn't have stumbled across this without your suggestions!

EvelynHernandez
Occasional Contributor III

Ur welcome . It will be useful if u write some code and show us how u solve ur problem cuz anyone else can have the same question.

0 Kudos