Select to view content in your preferred language

How to restrict identify layers

5759
32
03-10-2011 08:20 AM
DonFreeman
Emerging Contributor
Is there a way to restrict the layers that are returned with an identify query?
  private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
   {
   ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;

   ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
   {
    Geometry = clickPoint,
    MapExtent = MyMap.Extent,
    Width = (int)MyMap.ActualWidth,
    Height = (int)MyMap.ActualHeight,
    LayerOption = LayerOption.visible,
    SpatialReference = MyMap.SpatialReference
   };

   IdentifyTask identifyTask = new IdentifyTask("http://gismaps.pagnet.org/arcgis/rest/services/Interactive_TIP_2011/MapServer");
   identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
  
   identifyTask.ExecuteAsync(identifyParams);

   GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
   graphicsLayer.ClearGraphics();
   ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
   {
    Geometry = clickPoint,
    Symbol = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
   };
   graphicsLayer.Graphics.Add(graphic);
   }

I tried putting the layer numbers in the url but that did not work.
Thanks
0 Kudos
32 Replies
DominiqueBroux
Esri Frequent Contributor
AFAIK, the raster layers inside a map service are managed the same way than any feature layer.

How did you set the LayerOption and the LayerIds of your identify task?  If LayerOption is set to visible, it means that the identify is taking care of the scale and so will not identify the raster layers that are not visible at the current scale.
Could this be your case?

If your service is public, can you share the identify request that is sent to the service (use fiddler to get it)?
0 Kudos
RamonLira
Deactivated User
has four sets of layers and each group has thirteen layers. I want to identify the values �??�??of the thirteen layers depending on which group is active regardless of which only some are visible.

LayerOption is "all" and  identifyParams.LayerIds.AddRange(new int[] { 1,2,3,4,5,6,7,8,9,10,11,12,13 });

return value of layers 1 and 2

if modify:
identifyParams.LayerIds.AddRange(new int[] { 1,3,4,5,6,7,8,9,10,11,12,13 });

return value of layers 1 and 3

if modify:

identifyParams.LayerIds.AddRange(new int[] {10,11,13 });
return value of layers 10 and 11
0 Kudos
RamonLira
Deactivated User
AFAIK, the raster layers inside a map service are managed the same way than any feature layer.

How did you set the LayerOption and the LayerIds of your identify task?  If LayerOption is set to visible, it means that the identify is taking care of the scale and so will not identify the raster layers that are not visible at the current scale.
Could this be your case?

If your service is public, can you share the identify request that is sent to the service (use fiddler to get it)?


and I do not know where it is used fiddler, sorry
0 Kudos
RamonLira
Deactivated User
Oh it is read-only in the sense that the instance cannot be changed but the collection can be modified. 🙂
 
//identifyParameters.LayerIds = new System.Collections.Generic.List<int>(); <-- cannot change instance
identifyParameters.LayerIds.AddRange(new int[] { 1, 2 }); // can change collection 


You have a good weekend too.


help me please, i have problem with identify rasters layer, only return the value of first two layers,no matter how many layers I add

LayerOption is "all" and identifyParams.LayerIds.AddRange(new int[] { 1,2,3,4,5,6,7,8,9,10,11,12,13 });

returned value of layers 1 and 2

if modify:
identifyParams.LayerIds.AddRange(new int[] { 1,3,4,5,6,7,8,9,10,11,12,13 });

returned value of layers 1 and 3
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Is your service public and could you share the map service URL, so we could test our side?
0 Kudos
RamonLira
Deactivated User
Is your service public and could you share the map service URL, so we could test our side?


this is my service:

http://sag01.iie.org.mx/ArcGISServer/rest/services/RecursoEolico/MapServer
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi Ramon,

I tested with your service and I am not able to reproduce the issue.
After setting the LayerOption to 'all' and the LayerIds to the range 1-13 (as you did), the identify task returns the infos about the 13 raster layers. See attached screenshot.

So for me, everything seems OK.
0 Kudos
RamonLira
Deactivated User
Hi Ramon,

I tested with your service and I am not able to reproduce the issue.
After setting the LayerOption to 'all' and the LayerIds to the range 1-13 (as you did), the identify task returns the infos about the 13 raster layers. See attached screenshot.

So for me, everything seems OK.


Thank you, my code is wrong, I did with the example as you and  the query give me all values�??�??.

thank you very much dbroux
0 Kudos
BrandonCales
Regular Contributor
Got it working....

The code below will identify only visible layers, whether they are a parent layer or feature layer within a group layer....

        public List<int> checkVisibility()
        {           
            List<int> visibleLayers = new List<int>();

           
            if (MapLegend.LayerItems != null)
            {
               
               //look at feature layers in service layer [0]
               foreach (LayerItemViewModel enabledLyr in MapLegend.LayerItems[1].LayerItems) //Change this to [0], when MapLegend (xaml) specifies "LayerIDs="MainLayer"" -- [1] when not
               {
                   //look and non-grouped feature layers
                   if (enabledLyr.LayerItems == null)
                   {
                       //is it visible
                       if (enabledLyr.IsVisible)
                       {
                           //exclude specific layers (before InitializeComponent) ==> List<int> ExcludeLayerList = new List<int> { 13, 14 };
                           if (!ExcludeLayerList.Contains(enabledLyr.SubLayerID))
                           {
                               visibleLayers.Add(enabledLyr.SubLayerID);
                           }
                       }
                   }

                   //look and grouped feature layers
                   if (enabledLyr.LayerItems != null)
                   {
                       //loop through feature layers under parent group
                       for (int i = 0; i < enabledLyr.LayerItems.Count; i++)
                       {
                           //is it visible
                           if (enabledLyr.LayerItems.IsVisible)
                           {
                               //exclude specific layers ==> List<int> ExcludeLayerList = new List<int> { 13, 14 };
                               if (!ExcludeLayerList.Contains(enabledLyr.LayerItems.SubLayerID))
                               {
                                   visibleLayers.Add(enabledLyr.LayerItems.SubLayerID);   
                               }
                           }
                       }
                   }
               }
            }
           return visibleLayers;
        }
0 Kudos
BarraLoubna
Deactivated User
Hello,

I would like to specify the identify parameter to appear only the layers that are displayed in the list of layers, you can visualize my post here:

http://forums.arcgis.com/threads/71468-How-to-structure-the-Identify-tool-depending-on-the-visibilit...

Do you have any idea?
0 Kudos