Select to view content in your preferred language

How to set LayerIds in IdentifyParameters?

3672
3
07-01-2010 11:17 PM
UlfGrimhardt
Deactivated User
Hi

I want to set just one Layer to be identified by the Identify Function. I tried this code:

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                Geometry = clickPoint,
                MapExtent = map.Extent,
                Width = (int)map.ActualWidth,
                Height = (int)map.ActualHeight,
                LayerOption = LayerOption.visible,
                LayerIds = [0]
            };

But it doesnt work, so i would like to know how can i set the LayerIds value?
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor

i would like to know how can i set the LayerIds value?


Use Add or AddRange method of the LayerIds collection:
 
identifyParams.LayerIds.Add(1);
identifyParams.LayerIds.Add(3);
identifyParams.LayerIds.Add(5);
or
 
identifyParams.LayerIds.AddRange(new int[] { 1, 3, 5 });
0 Kudos
UlfGrimhardt
Deactivated User
Doesnt work.

VisualStudio underlines LayerIds with following Error:

Error Invalid initializer member declarator
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The methods can't be called in object initializer. Need to be called after.

 
ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
{
Geometry = clickPoint,
MapExtent = map.Extent,
Width = (int)map.ActualWidth,
Height = (int)map.ActualHeight,
LayerOption = LayerOption.visible
};
 
identifyParams.LayerIds.AddRange(new int[] { 1, 3, 5 });
... 
0 Kudos