Select to view content in your preferred language

How to use Layer Definitions in Identify Parameters?

4756
14
12-02-2011 09:51 AM
JoannaLaroussi
Emerging Contributor
I try to set my Identify tool to identify only the results of my query task instead all of them (this includes invisible). Setting LayerOption = LayerOption.visible does not work in my case, because the query task returns one result for polygon feature class and one for points, where the extent of polygons is much bigger than points. I would like to be able identify only these points, which were returned by a query, but all polygons. My guess is I should use Layer Definitions, but I do not know how exactly to do it. I tried something like this:
private void IdentifyStart()
        {
            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                Geometry = _clickPont,
                MapExtent = Map.Extent,
                Width = (int)Map.ActualWidth,
                Height = (int)Map.ActualHeight,
                SpatialReference = Map.SpatialReference,
                Tolerance = 10,
               
IEnumerable < "PreKSitesGraphicsLayer" > IdentifyParameters.LayerDefinitions, 
            };

But this is not working. Does someone have idea how to solve it, or can provide me with any code sample? Thank you!
0 Kudos
14 Replies
DominiqueBroux
Esri Frequent Contributor
That is the code that I used, and I don't get an error. However, identify still returns all layers for some reason.

Strange.
Try with LayerOption.visible instead of 'all'. 
Nevertheless I thought 'all' option  would work as well.
0 Kudos
JeffSauder
Regular Contributor
It does the same thing with all visible layers, for some reason will not return just the one layer.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
That's not normal.

If possible try using fiddler to look at the request sent to the server.

That might give a clue.
0 Kudos
JeffSauder
Regular Contributor
This is what fiddler shows being sent to the server:

GET /GilbertGIS/rest/services/GilbertPW/MapServer/identify?geometryType=esriGeometryEnvelope&geometry=%7b%22xmin%22%3a749079.006624349%2c%22ymin%22%3a849040.14211143%2c%22xmax%22%3a749701.296908102%2c%22ymax%22%3a849367.663313405%2c%22spatialReference%22%3a%7b%22wkid%22%3a2868%7d%7d&returnGeometry=true&imageDisplay=1695%2c851%2c96&layers=visible%3a0%2c0%2c1%2c2%2c3%2c4%2c5%2c6%2c7%2c8%2c9%2c10%2c11%2c12%2c13%2c14%2c15%2c16&tolerance=2&mapExtent=745070.147112175%2c845601.169490692%2c756173.115859128%2c851175.580348308&f=json& HTTP/1.1

It looks like after the layers=visible part the 3a0 is layer 0 in the layerid and the 2c parts that follow have each of the 17 layers.
0 Kudos
BarraLoubna
Deactivated User
Hello,

I would like to appear in the Identify combobox, just the layers that are visible in the list of layers.

I tried what you suggested in this post, but it does not work.

code :

...
List<int> visibleLayerList =
                 dynamicServiceLayer.VisibleLayers != null
                 ? dynamicServiceLayer.VisibleLayers.ToList() : new List<int>();

IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest/services/Limites_Administratives_Luxembourg/MapServer/");

...

identifyParameters.LayerIds.Add(visibleLayerList[IdentifyComboBox.SelectedIndex]);

Someone can help me?

Thank you.
0 Kudos