Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible filter out some features using a definition query set from the client on a AGS layer?

I've checked out the map server layer but it only supports find and identify. Also looked at WMS, WFS and the Feature Service. Can't find a way that works. Do I need to extend the AGS to get this functionality?

Update: What I'm trying to do is opening an MXD in an ArcGIS Engine application. The MXD has an ArcGIS Server map server layer. I would like to filter out some of the features in one of the ArcGIS Server layers by using an definition query.

share|improve this question
up vote 1 down vote accepted

I don't see an easy way to do this. But might be worth trying this:

Write a custom ILayer for arcgis that uses webclient to make a REST request that queries the mapservice layer. For the constructor pass the URL to the mapserverlayer, then insert the "rest" and append a where clause. Keep in mind REST urls are case sensitive. Using the returned JSON string, build an array of some POCO equivalent to IFeatures and loop through those when ILayer.Draw is called. It won't be fast, but WMS often isn't fast either.

If the service is running under 10.0 sp1, you should also be able to fetch any bitmaps used for rendering and make you own renderer in arcengine via IPictureMarkerSymbol.

share|improve this answer
Uh, not an easy solution indeed. How would you manage the map service's sublayers to be able to turn individual layers on/off? – Petr Krebs Nov 29 '10 at 21:47
Yes this is a possible way forward, but one drawback is that I need to configure and handle the layers myself. I don't like the fact that the FeatureService/REST layer isn't by default feature layers in ArcObjects. – MathiasWestin Nov 30 '10 at 9:22
I'm testing this out a bit (and yes we are running sp1) and I can create a request that returns the correct features. But I don't get how to create a renderer for polygons or lines. I'm not sure if I'm missing something obvious but if you are referring to the legend REST api:s it only returns bitmaps of the swatches. – MathiasWestin Dec 2 '10 at 15:21
Never mind, found DrawingInfo on the layer that gives the rendering information: – MathiasWestin Dec 2 '10 at 15:47
Used Kirks suggestions to make a sample that work using REST API for MapExport instead of map query, – MathiasWestin Feb 16 '11 at 14:42

Take a look at ILayerDescription:

share|improve this answer
The layer doesn't support that interface. – MathiasWestin Nov 29 '10 at 8:36

Have you tried the IMapServerSubLayer2.LayerDescription property? Map server layers do implement IMapServerSubLayer2, which allows you to access the layer description's DefinitionExpression.

share|improve this answer
Correct, I can access the LayerDescription on the IMapServerSubLayer, but it's read only, if I change the DefinitionExpression and call the LayerDescription property again on the layer it changes it back to an empty string. – MathiasWestin Nov 29 '10 at 10:08
I've sent this as an error report to ESRI. – MathiasWestin Nov 30 '10 at 9:16
We have also added an Idea on better ArcGIS Server support in Desktop and Engine: – MathiasWestin May 9 '11 at 13:38

here is what I found for flex... hope this is a start.

esri resource center

share|improve this answer
Thanks, but I'm trying to do this from ArcGIS Engine. – MathiasWestin Nov 24 '10 at 18:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.