Identify and Points

625
4
02-28-2011 04:05 PM
AngelGonzalez
Occasional Contributor II
OK, I got the identify to work correctly in my silverlight app. but I have a problem when selecting a point feature. The points on my layer are represented as circles or squares (large and small depending on the type). When I click on the circle or square to identify the point sometime the underlying point is selected, sometime it is not and I have to click on the circle or square again to select the point. Is their some way to "expand" geometry of the clickpoint so that it can select a larger area.
0 Kudos
4 Replies
Charles__Jamie_Phillips
New Contributor III
I put a comment below, but basically when setting the Geometry of the identify just expand the extent of the point by however much you want.  This example does 10%.

 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()
         {
            //Just get the extent and expand it, this one is expanded by 10%
            Geometry = clickPoint.Extent.Expand(1.1),
            MapExtent = MyMap.Extent,
            Width = (int)MyMap.ActualWidth,
            Height = (int)MyMap.ActualHeight,
            LayerOption = LayerOption.visible,
            SpatialReference = MyMap.SpatialReference
         };

         IdentifyTask identifyTask = new IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
             "Demographics/ESRI_Census_USA/MapServer");
         identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
         identifyTask.Failed += IdentifyTask_Failed;
         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);
      }
0 Kudos
AngelGonzalez
Occasional Contributor II
I tried your code modification:

//Just get the extent and expand it, this one is expanded by 10%
            Geometry = clickPoint.Extent.Expand(1.1),



Once I tried it I could not identify any point features at all. If I removed the modification I can once again identify point feature.  I also found out that by using your modification line features are not being identified either for some reason. Are you able to identify both lines and point using the modification?

Thanks
0 Kudos
AngelGonzalez
Occasional Contributor II
OK, I got it to work. The IdentifyParameters has a property called Tolerance. By setting this property to a value of 5 I can now get the nearby point features.

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,
            Tolerance = 5,
            MapExtent = MyMap.Extent,
            Width = (int)MyMap.ActualWidth,
            Height = (int)MyMap.ActualHeight,
            LayerOption = LayerOption.visible,
            SpatialReference = MyMap.SpatialReference
         };

         IdentifyTask identifyTask = new IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
             "Demographics/ESRI_Census_USA/MapServer");
         identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
         identifyTask.Failed += IdentifyTask_Failed;
         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);
      }
0 Kudos
DeeptiVB
New Contributor II
Glad to have found this post. I had a similar problem, a point layer which was playing hide-n-seek while using the identify button. Was not sure whether it had to do with the layer ordering - all the other layers being polygons or tolerance. Set tolerance (=screen pixels) to 10 and it works good. Thank you, Angel. Here are all the class members of IdentifyParameters.
0 Kudos