<?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: Graphic marker query in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-marker-query/m-p/1227160#M79184</link>
    <description>&lt;P&gt;The call to hitTest as you have it will query every single layer in the view, and the graphic will be added to the map if any feature from any layer in the view intersects the hit point.&amp;nbsp; Here, I'm assuming your county boundaries layer is a polygon, and so the hitTest is intersecting that polygon.&amp;nbsp; Therefore, since the hitTest intersects a feature, your graphic is placed on the map.&lt;/P&gt;&lt;P&gt;You need to tell the hitTest method to only query against your streets layer, and that can be done in the second argument (called "options" in the documentation) to &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest" target="_self"&gt;hitTest&lt;/A&gt;.&amp;nbsp; For example (assuming you have a reference to your layer with a variable named "streetsLayer"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.hitTest(evt, {include:streetsLayer}).then(({results}) =&amp;gt; {
	if (results.length) {
		view.graphics.removeAll();
		view.graphics.add(graphic);
	}
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2022 18:12:03 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2022-10-31T18:12:03Z</dc:date>
    <item>
      <title>Graphic marker query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-marker-query/m-p/1226985#M79172</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;I'm hoping this is a simple query. On my map a customer is restricted to dropping a simple marker on our streets feature layer only. This stops customers dropping markers in fields or any other area when reporting an issue with a street. This happens via a hitTest event on the graphics (see sample below).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.on("click", function (evt) {
          var graphic = new Graphic({
            geometry: {
              type: "point",
              x: evt.mapPoint.x,
              y: evt.mapPoint.y,
              spatialReference: view.spatialReference,
            },
            symbol: {
              type: "simple-marker",
              color: [255, 10, 10],
            outline: {
              color: [255, 255, 255],
              width: 2,
              },
            },
          });
        
        view.hitTest(evt).then(({results}) =&amp;gt; {
          if (results.length) {
            view.graphics.removeAll();
            view.graphics.add(graphic);
          }
        });
       });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This currently works brilliantly.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ITApplications_0-1667210431092.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/54798iD650D50DA642D201/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ITApplications_0-1667210431092.png" alt="ITApplications_0-1667210431092.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However if I add another feature layer to the map (in this case our county boundary layer), the restrict to hitTest part of the query for the graphics marker is ignored and it lets a customer drop a marker anywhere of their choosing.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ITApplications_1-1667210516940.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/54799iF79930C2FB719E19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ITApplications_1-1667210516940.png" alt="ITApplications_1-1667210516940.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why is it doing this and what can I do to mitigate it? The hitTest is only linked to the streets layer and that part still works fine when a street in interacted with, it's just the graphics query which seems to be ignored now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got my roads feature layer to load as 0 and the boundary layer as 1.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 10:09:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-marker-query/m-p/1226985#M79172</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-10-31T10:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic marker query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-marker-query/m-p/1227160#M79184</link>
      <description>&lt;P&gt;The call to hitTest as you have it will query every single layer in the view, and the graphic will be added to the map if any feature from any layer in the view intersects the hit point.&amp;nbsp; Here, I'm assuming your county boundaries layer is a polygon, and so the hitTest is intersecting that polygon.&amp;nbsp; Therefore, since the hitTest intersects a feature, your graphic is placed on the map.&lt;/P&gt;&lt;P&gt;You need to tell the hitTest method to only query against your streets layer, and that can be done in the second argument (called "options" in the documentation) to &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest" target="_self"&gt;hitTest&lt;/A&gt;.&amp;nbsp; For example (assuming you have a reference to your layer with a variable named "streetsLayer"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.hitTest(evt, {include:streetsLayer}).then(({results}) =&amp;gt; {
	if (results.length) {
		view.graphics.removeAll();
		view.graphics.add(graphic);
	}
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 18:12:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-marker-query/m-p/1227160#M79184</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-10-31T18:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic marker query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-marker-query/m-p/1227374#M79189</link>
      <description>&lt;P&gt;Hi Joel&lt;/P&gt;&lt;P&gt;Your assumptions were all correct and that's worked perfectly! Thank you for your&amp;nbsp; assistance.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Ricky&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 09:05:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-marker-query/m-p/1227374#M79189</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-11-01T09:05:07Z</dc:date>
    </item>
  </channel>
</rss>

