AnsweredAssumed Answered

Hit Testing Polygons in a GraphicsOverlay

Question asked by KevinSayer on Feb 1, 2017
Latest reply on Feb 13, 2017 by JNery-esristaff

We've been having problems with the Quartz SDK whilst hit testing polygons in a GraphicsOverlay.  We are calling IdentifyGraphicsOverlayAsync on the MapView and setting the tolerance parameter to 0 for precise selection and the maximumResults parameter to 1.  The IdentifyGraphicsOverlayResult.Graphics collection seems to intermittently contain no graphics.

 

We've played around with the parameters and either setting the tolerance to at least 3 or the maximumResults to 10 (arbitrarliy selected), seems to fix this.  Is this expected and explainable behaviour or is there a bug in the implementation?  Intuitively, neither of the parameters mentioned seem as though they should make any difference to the behaviour.

 

This problem is easily reproducible in the ArcGIS Runtime SDK for .Net Samples by changing the OnMapTapped implementation in the IdentifyGraphics example to the following:

 

        private async void OnMapViewTapped(object sender, GeoViewInputEventArgs e)
        {
            var tolerance = 0d; // Use larger tolerance for touch
            var maximumResults = 1; // Only return one graphic  
            var onlyReturnPopups = false; // Return more than popups

 

            // Use the following method to identify graphics in a specific graphics overlay
           IdentifyGraphicsOverlayResult identifyResults = await MyMapView.IdentifyGraphicsOverlayAsync(
                _polygonOverlay,
                e.Position,
                tolerance,
                onlyReturnPopups,
                maximumResults);

 

            // Check if we got results

            if (identifyResults.Graphics.Count > 0)
            {
                foreach (var graphic in identifyResults.Graphics)
                {
                    graphic.IsSelected = true;
                }
            }
            else
            {
                foreach (var graphic in _polygonOverlay.Graphics)
                {
                    graphic.IsSelected = false;
                }
            }
        }

Outcomes