<?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: question about mouse events for graphics in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80255#M7358</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll want to use the &lt;EM&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest" rel="nofollow noopener noreferrer" target="_blank"&gt;view.hitTest&lt;/A&gt;​&lt;/EM&gt; method to get graphics in the View.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;view.on("click", function(event) {
&amp;nbsp; view.hitTest(event.screenPoint).then(function(response) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphics = response.results;
&amp;nbsp;&amp;nbsp;&amp;nbsp; graphics.forEach(function(graphic) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(graphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp; });
});&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The benefit here over how you would have done it in 3.x is that in 3.x you would only get the top-most graphic that was clicked. Now you'll get any graphics under the location where you clicked by using the hitTest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also look at this sample.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/sandbox.html?sample=layers-scenelayer-query-popup" title="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/sandbox.html?sample=layers-scenelayer-query-popup" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcGIS API for JavaScript Sandbox&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:05:42 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2021-12-10T23:05:42Z</dc:date>
    <item>
      <title>question about mouse events for graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80254#M7357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;How do you listen for mouse clicks on graphics in a graphics layer in 4.0?&amp;nbsp; I can listen for mouse clicks on a view, but how do I know which graphic element was clicked on if any?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 15:55:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80254#M7357</guid>
      <dc:creator>JustinJackson</dc:creator>
      <dc:date>2016-05-19T15:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: question about mouse events for graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80255#M7358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll want to use the &lt;EM&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest" rel="nofollow noopener noreferrer" target="_blank"&gt;view.hitTest&lt;/A&gt;​&lt;/EM&gt; method to get graphics in the View.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;view.on("click", function(event) {
&amp;nbsp; view.hitTest(event.screenPoint).then(function(response) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphics = response.results;
&amp;nbsp;&amp;nbsp;&amp;nbsp; graphics.forEach(function(graphic) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(graphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp; });
});&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The benefit here over how you would have done it in 3.x is that in 3.x you would only get the top-most graphic that was clicked. Now you'll get any graphics under the location where you clicked by using the hitTest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also look at this sample.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/sandbox.html?sample=layers-scenelayer-query-popup" title="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/sandbox.html?sample=layers-scenelayer-query-popup" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcGIS API for JavaScript Sandbox&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:05:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80255#M7358</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-10T23:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: question about mouse events for graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80256#M7359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 16:48:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80256#M7359</guid>
      <dc:creator>JustinJackson</dc:creator>
      <dc:date>2016-05-19T16:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: question about mouse events for graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80257#M7360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what about mouseover??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2016 15:07:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80257#M7360</guid>
      <dc:creator>hebasaleh</dc:creator>
      <dc:date>2016-08-18T15:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: question about mouse events for graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80258#M7361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The View doesn't have a mouseover event at this time. You could try listening for mouseover on the View container.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2016 15:34:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80258#M7361</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2016-08-18T15:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: question about mouse events for graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80259#M7362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;OL class="" start="1" style="color: #5c5c5c; background-color: #ffffff; border: none; font-size: 12px; margin: 0px 0px 1px 45px !important;"&gt;&lt;LI class="" style="color: inherit; background-color: #ffffff; border-top: none; border-bottom: none; border-left: 3px solid #6ce26c; border-right: none; font-weight: inherit; font-size: 12px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"&gt;&lt;SPAN style="color: black; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;view.on(&lt;SPAN class="" style="color: blue; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;"click"&lt;/SPAN&gt;,&amp;nbsp;&lt;SPAN class="" style="color: #0088e1; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;function&lt;/SPAN&gt;(event)&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="" style="color: #5c5c5c; background-color: #f6f6f6; border-top: none; border-bottom: none; border-left: 3px solid #6ce26c; border-right: none; font-weight: inherit; font-size: 12px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"&gt;&lt;SPAN style="color: black; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;&amp;nbsp;&amp;nbsp;view.hitTest(event.screenPoint).then(&lt;SPAN class="" style="color: #0088e1; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;function&lt;/SPAN&gt;(response)&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="" style="color: inherit; background-color: #ffffff; border-top: none; border-bottom: none; border-left: 3px solid #6ce26c; border-right: none; font-weight: inherit; font-size: 12px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"&gt;&lt;SPAN style="color: black; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="" style="color: #0088e1; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;var&lt;/SPAN&gt;&amp;nbsp;graphics&amp;nbsp;=&amp;nbsp;response.results;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="" style="color: #5c5c5c; background-color: #f6f6f6; border-top: none; border-bottom: none; border-left: 3px solid #6ce26c; border-right: none; font-weight: inherit; font-size: 12px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"&gt;&lt;SPAN style="color: black; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;graphics.forEach(&lt;SPAN class="" style="color: #0088e1; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;function&lt;/SPAN&gt;(graphic)&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="" style="color: inherit; background-color: #ffffff; border-top: none; border-bottom: none; border-left: 3px solid #6ce26c; border-right: none; font-weight: inherit; font-size: 12px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"&gt;&lt;SPAN style="color: black; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(graphic);&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="" style="color: #5c5c5c; background-color: #f6f6f6; border-top: none; border-bottom: none; border-left: 3px solid #6ce26c; border-right: none; font-weight: inherit; font-size: 12px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"&gt;&lt;SPAN style="color: black; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="" style="color: inherit; background-color: #ffffff; border-top: none; border-bottom: none; border-left: 3px solid #6ce26c; border-right: none; font-weight: inherit; font-size: 12px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"&gt;&lt;SPAN style="color: black; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;&amp;nbsp;&amp;nbsp;});&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="" style="color: #5c5c5c; background-color: #f6f6f6; border-top: none; border-bottom: none; border-left: 3px solid #6ce26c; border-right: none; font-weight: inherit; font-size: 12px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"&gt;&lt;SPAN style="color: black; background-color: inherit; border: 0px; font-weight: inherit; font-size: 9pt !important;"&gt;});&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Another question on the graphics object.&lt;/P&gt;&lt;P&gt;How can we use 4.0 library (For example:&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/sample-code/get-started-graphics/index.html" title="https://developers.arcgis.com/javascript/latest/sample-code/get-started-graphics/index.html"&gt;Get started with graphics | ArcGIS API for JavaScript 4.0&lt;/A&gt;&amp;nbsp;&amp;nbsp;) to draw the graphic in the map(Although the x,y value of the point/polyline/polygon can be found in the object)? is there any better way to do it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2016 04:01:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80259#M7362</guid>
      <dc:creator>IanNi</dc:creator>
      <dc:date>2016-08-25T04:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: question about mouse events for graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80260#M7363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;A href="https://community.esri.com/migrated-users/6443"&gt;Rene Rubalcava&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This doesn't seem to be working properly as far as I can tell. When I add 'console.log(response);' on line 129 to the &lt;A href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fdevelopers.arcgis.com%2Fjavascript%2Flatest%2Fsample-code%2Fsandbox%2Fsandbox.html%3Fsample%3Dlayers-scenelayer-query-popup"&gt;Sandbox example&lt;/A&gt;&amp;nbsp;I only get the&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;top-most graphic wherever I click, and not all graphics like you suggested&lt;/SPAN&gt;. The same holds for &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/sandbox.html?sample=view-hittest"&gt;this hitTest example&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I encounter the same problem in my own project, running the 4.0 API. The hitTest does return the top-most&amp;nbsp;graphic for each layer under the click, but never multiple graphics from a single layer. Do you know how to fix this? Or am I doing something wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Björn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2016 16:54:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80260#M7363</guid>
      <dc:creator>BjörnJanson</dc:creator>
      <dc:date>2016-11-29T16:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: question about mouse events for graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80261#M7364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I should have clarified earlier. It's only going to return one graphic per layer. This is because it would get expensive to try and recurse over the SVG to find overlapping features. If this changes in the future, I'll update here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2016 18:04:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-mouse-events-for-graphics/m-p/80261#M7364</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2016-11-29T18:04:09Z</dc:date>
    </item>
  </channel>
</rss>

