<?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: How to make a Popup show only one feature when the mouse clicks on a spot where multiple features meet in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-make-a-popup-show-only-one-feature-when-the/m-p/1524818#M85453</link>
    <description>&lt;P&gt;I tried this, but it doesn't seem to work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    reactiveUtils.when(() =&amp;gt; view.ready, () =&amp;gt; {
      view.on('click', async (event) =&amp;gt; {
        const response = await view.hitTest(event);
  
        if (response.results.length &amp;gt; 0) {
          // Filter results to only those from the assessorParcelsMap
          const parcelResults = response.results.filter((result) =&amp;gt; {
            return result.type === 'graphic' &amp;amp;&amp;amp; result.graphic.layer === assessorParcelsMap;
          }) as __esri.GraphicHit[];
  
          if (parcelResults.length &amp;gt; 0) {
            const clickedPoint = view.toMap({ x: event.x, y: event.y }) as Point;
  
            // Find the closest parcel using the geometryEngine.distance method
            const closestFeature = parcelResults.reduce(
              (closest, feature) =&amp;gt; {
                const geometry = feature.graphic.geometry;
                const distance = geometryEngine.distance(geometry, clickedPoint);
  
                return distance !== null &amp;amp;&amp;amp; distance &amp;lt; closest.distance
                  ? { graphic: feature.graphic, distance }
                  : closest;
              },
              { graphic: null as Graphic | null, distance: Infinity }
            );
  
            if (closestFeature.graphic) {
              view.popup.open({
                features: [closestFeature.graphic],
                location: closestFeature.graphic.geometry as __esri.Geometry,
              });
            }
          }
        }
      });
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 23:11:14 GMT</pubDate>
    <dc:creator>andrewc213</dc:creator>
    <dc:date>2024-08-21T23:11:14Z</dc:date>
    <item>
      <title>How to make a Popup show only one feature when the mouse clicks on a spot where multiple features meet</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-make-a-popup-show-only-one-feature-when-the/m-p/1524737#M85449</link>
      <description>&lt;P&gt;I have a Layer containing land parcels that are drawn with purple lines. Ideally, a single click right on a parcel (regardless if the mouse clicks on a spot right on or near the purple border) should activate a Popup that shows only that parcel:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="andrewc213_2-1724185699161.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/113013i9CE31093E3BA3060/image-size/medium?v=v2&amp;amp;px=400" role="button" title="andrewc213_2-1724185699161.png" alt="andrewc213_2-1724185699161.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, clicking right on a point (or clicking right next to a purple line) where multiple parcels touch will fetch multiple parcels.&lt;/P&gt;&lt;P&gt;No Popup appears when clicking right on the point where Aragon Ave and Maceo St intersect:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="andrewc213_0-1724179948430.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/112977i016BFA0811D14E36/image-size/medium?v=v2&amp;amp;px=400" role="button" title="andrewc213_0-1724179948430.png" alt="andrewc213_0-1724179948430.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, when I zoom out as far as possible and click on the exact same spot, four parcels are yielded (the four parcels at the four corners of the intersection):&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="andrewc213_1-1724180014659.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/112979i5BAC5E91D1897CDD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="andrewc213_1-1724180014659.png" alt="andrewc213_1-1724180014659.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So it seems that&amp;nbsp;&lt;SPAN&gt;what's going on is this: the area of effect of a mouse click is not a single pixel point on the screen, but rather a small circle, and the size of that circle is fixed regardless of how close or far the MapView is zoomed (basically the map's scale doesn't seem to matter; the circular area of effect is the same physical size on the screen). Whichever parcel(s) are touched by that circular area of effect will be accounted for in the Popup. What I would like to do is have the Popup consider only one of the potentially multiple parcels that are gathered. The one parcel I want taken into account is the one closest to the mouse click point.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 20:37:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-make-a-popup-show-only-one-feature-when-the/m-p/1524737#M85449</guid>
      <dc:creator>andrewc213</dc:creator>
      <dc:date>2024-08-20T20:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a Popup show only one feature when the mouse clicks on a spot where multiple features meet</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-make-a-popup-show-only-one-feature-when-the/m-p/1524818#M85453</link>
      <description>&lt;P&gt;I tried this, but it doesn't seem to work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    reactiveUtils.when(() =&amp;gt; view.ready, () =&amp;gt; {
      view.on('click', async (event) =&amp;gt; {
        const response = await view.hitTest(event);
  
        if (response.results.length &amp;gt; 0) {
          // Filter results to only those from the assessorParcelsMap
          const parcelResults = response.results.filter((result) =&amp;gt; {
            return result.type === 'graphic' &amp;amp;&amp;amp; result.graphic.layer === assessorParcelsMap;
          }) as __esri.GraphicHit[];
  
          if (parcelResults.length &amp;gt; 0) {
            const clickedPoint = view.toMap({ x: event.x, y: event.y }) as Point;
  
            // Find the closest parcel using the geometryEngine.distance method
            const closestFeature = parcelResults.reduce(
              (closest, feature) =&amp;gt; {
                const geometry = feature.graphic.geometry;
                const distance = geometryEngine.distance(geometry, clickedPoint);
  
                return distance !== null &amp;amp;&amp;amp; distance &amp;lt; closest.distance
                  ? { graphic: feature.graphic, distance }
                  : closest;
              },
              { graphic: null as Graphic | null, distance: Infinity }
            );
  
            if (closestFeature.graphic) {
              view.popup.open({
                features: [closestFeature.graphic],
                location: closestFeature.graphic.geometry as __esri.Geometry,
              });
            }
          }
        }
      });
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 23:11:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-make-a-popup-show-only-one-feature-when-the/m-p/1524818#M85453</guid>
      <dc:creator>andrewc213</dc:creator>
      <dc:date>2024-08-21T23:11:14Z</dc:date>
    </item>
  </channel>
</rss>

