Select to view content in your preferred language

Display selective features from a layer?

2867
16
Jump to solution
08-12-2013 10:10 AM
JatinPatel
Regular Contributor
I have a layer (Not a feature layer). Is it possible to display only a few selected (based on a query) features from that layer on the map?
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
The layerDefinitions property can be used to filter the features of the individual layers in a map service. Take a look at the code snippet.

View solution in original post

0 Kudos
16 Replies
KenBuja
MVP Esteemed Contributor
The layerDefinitions property can be used to filter the features of the individual layers in a map service. Take a look at the code snippet.
0 Kudos
JatinPatel
Regular Contributor
Thanks Ken!!
0 Kudos
JatinPatel
Regular Contributor
The layerDefinitions property can be used to filter the features of the individual layers in a map service. Take a look at the code snippet.


Ken,
Is it possible to set a criteria using geometry in this case?
0 Kudos
ZachLiu1
Deactivated User
Do you mean selection by location?

You can define a QueryTask and in your Query definition you can set your query geometry and type of relationship, and display only the features you want in a graphic layer.

Hope this will help.
0 Kudos
JatinPatel
Regular Contributor
Do you mean selection by location?

You can define a QueryTask and in your Query definition you can set your query geometry and type of relationship, and display only the features you want in a graphic layer.

Hope this will help.


Querytask will not work. It can only create a dummy graphic on top of the layer, I would like to actually display the layer itself with only the features that fall inside a certain geometry, just like layerDefinitions for an attribute criteria.
0 Kudos
JasonZou
Frequent Contributor
There is no easy solution for what you need. One option I can think of is like the following workflow.

  • Create a feature layer

  • Set its renderer to blank symbol so that no features will be displayed.

  • setSelectionSymbol to symbols for the selected features.

  • Use selectFeatures to apply the criteria defined by both attributes and geometries.


This way, it will only display the features filtered by attributes and geometries.
0 Kudos
VinayBansal
Frequent Contributor
There is no direct solution. Other option can be....

Use querytask to get the objectIds of the features of layer within the geometry.
And then set the layerDefinitionExpression for the the layer by passing the returned ObjectIds. Like OBJECTID IN (1,2,3.......)


But there might be the limitations of number of objectid's to be passed to the layerdefinition expression. If records returned are more...
0 Kudos
JatinPatel
Regular Contributor
There is no direct solution. Other option can be....

Use querytask to get the objectIds of the features of layer within the geometry.
And then set the layerDefinitionExpression for the the layer by passing the returned ObjectIds. Like OBJECTID IN (1,2,3.......)


But there might be the limitations of number of objectid's to be passed to the layerdefinition expression. If records returned are more...


Thanks Vinay... I think that will solve my problem...!!
0 Kudos
AlessioDi_Lorenzo
Emerging Contributor
There is no direct solution. Other option can be....

Use querytask to get the objectIds of the features of layer within the geometry.
And then set the layerDefinitionExpression for the the layer by passing the returned ObjectIds. Like OBJECTID IN (1,2,3.......)


But there might be the limitations of number of objectid's to be passed to the layerdefinition expression. If records returned are more...


Hi,

I am using exactly this approach to obtain a server-side response to a buffer query. The problem is that it works until the returned features (points, in my case) are 999. Then arcgis server returns a blank image in my arcgisoutput directory.
I already set the maxRecordCount variable to 5000.
Any help?
Thank you!
0 Kudos