<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Buffering a click in screen space in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1327966#M10379</link>
    <description>&lt;LI-CODE lang="csharp"&gt;protected override async Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry) {
    return await QueuedTask.Run&amp;lt;bool&amp;gt;(async () =&amp;gt; {
        // geometry is a point
        var clickedPnt = geometry as MapPoint;
        if (clickedPnt == null)
            return false;

        float tolerance = 4.0f; // Buffer size

        // Take the screen-space point and buffer it by the tolerance
        var topLeft = new Coordinate2D(clickedPnt.X - tolerance, clickedPnt.Y + tolerance);
        var bottomRight = new Coordinate2D(clickedPnt.X + tolerance, clickedPnt.Y - tolerance);

        Geometry envelopeGeometry = EnvelopeBuilderEx.CreateEnvelope(topLeft, bottomRight);
        if (envelopeGeometry == null)
            return false;

        var result = ActiveMapView.GetFeatures(envelopeGeometry);

        foreach (var kvp in result.ToDictionary()){
            // Do Stuff
        }

        return true; // Return T/F based on the above loop
    });
}&lt;/LI-CODE&gt;&lt;P&gt;Thanks for pointing me to that!&lt;BR /&gt;I found a mistake in that example, though. The envelope created is never used, and if it were used, it wouldn't find the correct target due to a differing spatial reference id.&lt;BR /&gt;Here is the correct code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Sep 2023 21:01:05 GMT</pubDate>
    <dc:creator>MBambino_ATS</dc:creator>
    <dc:date>2023-09-12T21:01:05Z</dc:date>
    <item>
      <title>Buffering a click in screen space</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1327773#M10375</link>
      <description>&lt;P&gt;I have a Map Tool that listens for a click on the map to then search for shapes (mainly lines and points). I already have the settings enabled to use the visual shape to increase the click area, but is it possible to extend that even further? I know that you can use a circle to increase the search area, but that makes zoomed-in clicks much wider than zoomed out clicks. Is there a way to scale the circle to the screen size, so for example, I would search and extra 4 pixels in all directions?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 15:26:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1327773#M10375</guid>
      <dc:creator>MBambino_ATS</dc:creator>
      <dc:date>2023-09-12T15:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Buffering a click in screen space</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1327794#M10376</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Look at ArcGIS Pro SDK community &lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/MapToolWithDynamicMenu" target="_self"&gt;sample&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It uses MapTool with&amp;nbsp;SketchOutputMode equal SketchOutputMode.Screen.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In&amp;nbsp;OnToolActivateAsync method it expands clicked point extent by 3 pixels.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 15:44:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1327794#M10376</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-09-12T15:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Buffering a click in screen space</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1327966#M10379</link>
      <description>&lt;LI-CODE lang="csharp"&gt;protected override async Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry) {
    return await QueuedTask.Run&amp;lt;bool&amp;gt;(async () =&amp;gt; {
        // geometry is a point
        var clickedPnt = geometry as MapPoint;
        if (clickedPnt == null)
            return false;

        float tolerance = 4.0f; // Buffer size

        // Take the screen-space point and buffer it by the tolerance
        var topLeft = new Coordinate2D(clickedPnt.X - tolerance, clickedPnt.Y + tolerance);
        var bottomRight = new Coordinate2D(clickedPnt.X + tolerance, clickedPnt.Y - tolerance);

        Geometry envelopeGeometry = EnvelopeBuilderEx.CreateEnvelope(topLeft, bottomRight);
        if (envelopeGeometry == null)
            return false;

        var result = ActiveMapView.GetFeatures(envelopeGeometry);

        foreach (var kvp in result.ToDictionary()){
            // Do Stuff
        }

        return true; // Return T/F based on the above loop
    });
}&lt;/LI-CODE&gt;&lt;P&gt;Thanks for pointing me to that!&lt;BR /&gt;I found a mistake in that example, though. The envelope created is never used, and if it were used, it wouldn't find the correct target due to a differing spatial reference id.&lt;BR /&gt;Here is the correct code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:01:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1327966#M10379</guid>
      <dc:creator>MBambino_ATS</dc:creator>
      <dc:date>2023-09-12T21:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Buffering a click in screen space</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1328515#M10387</link>
      <description>&lt;P&gt;Thanks for pointing out the issue with the sample, i will correct the issue for the upcoming 3.2 release.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;This code uses a circle around the click point using the pixel tolerance as the radius:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// pixel tolerance
var toleranceInScreenUnits = 10;
// Use bottomRight to popup the dynamic menu result
bottomRight = new Point(clickedPnt.X + toleranceInScreenUnits, clickedPnt.Y + toleranceInScreenUnits);
var toleranceInMapUnits = GetScreenPointsInMapUnits(toleranceInScreenUnits, MapView.Active);

// Create a search circle around the click point using the pixel tolerance as a radius
var pnt = MapView.Active.ClientToMap(new Point(clickedPnt.X, clickedPnt.Y));
var arcSegment = EllipticArcBuilderEx.CreateCircle(pnt.Coordinate2D, toleranceInMapUnits, ArcOrientation.ArcClockwise, pnt.SpatialReference);
var circlePolygon = PolygonBuilderEx.CreatePolygon(new[] { arcSegment });

//Get the features that intersect the search circle polygon
var result = ActiveMapView.GetFeatures(circlePolygon);&lt;/LI-CODE&gt;&lt;P&gt;Here is a screenshot that show the search polygon on the map:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1694641934894.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/80648i178BE9243C580811/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1694641934894.png" alt="Wolf_0-1694641934894.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 21:52:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1328515#M10387</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-09-13T21:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Buffering a click in screen space</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1328641#M10390</link>
      <description>&lt;P&gt;Thank you for that!&lt;BR /&gt;Where does GetScreenPointsInMapUnits come from?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 12:24:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1328641#M10390</guid>
      <dc:creator>MBambino_ATS</dc:creator>
      <dc:date>2023-09-14T12:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Buffering a click in screen space</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1328926#M10397</link>
      <description>&lt;P&gt;Sorry i forgot to include the &lt;SPAN&gt;GetScreenPointsInMapUnits&amp;nbsp;&lt;/SPAN&gt;method in my snippet above.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private double GetScreenPointsInMapUnits (double pixels, MapView mapView)
{
  var left = new Point(0, 0);
  var right = new Point(0, pixels);
  var pntLeft = mapView.ClientToMap(left);
  var pntRight = mapView.ClientToMap(right);
  var line = LineBuilderEx.CreateLineSegment (pntLeft, pntRight);
  return line.Length;
}&lt;/LI-CODE&gt;&lt;P&gt;In essence the method takes the tolerance in screen units (i.e. pixels) and returns the tolerance in units for the current active map's spatial reference.&amp;nbsp; So when i generate the circle geometry for the search i can then use&amp;nbsp;toleranceInMapUnits as the radius for the circle.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 22:44:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/buffering-a-click-in-screen-space/m-p/1328926#M10397</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-09-14T22:44:02Z</dc:date>
    </item>
  </channel>
</rss>

