<?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: Limit drop marker to feature in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1175463#M77391</link>
    <description>&lt;P&gt;That's excellent and working well, thank you. I did try taking the top line out but I'd missed taking out the } right at the bottom and that clearly now was my error!&lt;/P&gt;&lt;P&gt;thank you so much for your patience, help and advice.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 May 2022 08:12:34 GMT</pubDate>
    <dc:creator>ITApplications</dc:creator>
    <dc:date>2022-05-19T08:12:34Z</dc:date>
    <item>
      <title>Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173323#M77283</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;When zoomed in and the streets feature layer is available we are able to drop a graphic marker anywhere on the map.&lt;/P&gt;&lt;P&gt;I'd like to limit the graphic marker to be only able to drop it onto the feature (street) and not just anywhere on the map.&lt;/P&gt;&lt;P&gt;How can I do that?&lt;/P&gt;&lt;P&gt;This map will be used for reporting potholes on a street and the graphic will serve no other service other than visually showing (along with the popup that appears when you click on the feature) where someone has clicked to report the location of the pothole.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 08:13:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173323#M77283</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-05-19T08:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173341#M77284</link>
      <description>&lt;P&gt;You can check the length of the graphics layer collection.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (!view.graphics.length) {
    view.graphics.removeAll();
    view.graphics.add(graphic);
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 12 May 2022 14:45:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173341#M77284</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-05-12T14:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173354#M77285</link>
      <description>&lt;P&gt;Hi Rene&lt;/P&gt;&lt;P&gt;Thank you for your advice. I'm really new to API's and am just trying to learn the ropes, can you please advise where I would pop that in my particular code and is there anything else I'd need to modify?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 15:05:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173354#M77285</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-05-12T15:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173416#M77286</link>
      <description>&lt;P&gt;Here you go, I made a fork of your codepen showing where to add it.&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/odoe/pen/RwQGxbP?editors=0010" target="_blank"&gt;https://codepen.io/odoe/pen/RwQGxbP?editors=0010&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 16:14:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173416#M77286</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-05-12T16:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173627#M77295</link>
      <description>&lt;P&gt;Hi Rene&lt;/P&gt;&lt;P&gt;Thank you. I've put the code in exactly as you have and sadly I'm still able to drop a marker anywhere on the map, it's not restricting it to the feature. I have a hit test on the streets feature layer (see example below) and I want to restrict the marker to only be dropped on this.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Your codepen is also still letting me drop a marker outside of this limitation.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ITApplications_0-1652434483965.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41294iF0F4C75B6B3132D4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ITApplications_0-1652434483965.png" alt="ITApplications_0-1652434483965.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm thinking, could I put the create graphic event inside the IF part of&amp;nbsp; hittest query? Therefore if the hittest is true allow the graphic to be created, else don't? I've tried to play around that but can't get it to work.&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 09:45:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173627#M77295</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-05-13T09:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173810#M77300</link>
      <description>&lt;P&gt;Sorry, I misunderstood what you were looking for. You can use a hitTest to check if your layer where you clicked. I would normally do more checks for the layer id or title, but in this case just checking for results is ok.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (!view.graphics.length) {
  // check if layer where you clicked
  // with hitTest
  view.hitTest(evt).then(({results}) =&amp;gt; {
    if (results.length) {
      view.graphics.removeAll();
      view.graphics.add(graphic);
    }
  });
}&lt;/LI-CODE&gt;&lt;P&gt;I updated the codepen in my previous post.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 17:32:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1173810#M77300</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-05-13T17:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1174137#M77315</link>
      <description>&lt;P&gt;Hi Rene&lt;/P&gt;&lt;P&gt;Thank you for the update. I can confirm that is has now restricted the graphic to just on the feature layer. There is only one minor tweak that I need to make. On my original codepen (see link in topmost post) the graphic reset itself the next time you clicked on the map. I'd like it to still do this when clicking on the feature layer.&lt;/P&gt;&lt;P&gt;The code to restrict the graphic to only to the feature layer seems to have restricted it to one click only unless you reset it using the reset button I have. I've decided I no longer need the reset button (which I'll remove) and instead would just like the next click to reset and replace the graphic.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I please tweak your code to allow this? I'm then there.&lt;/P&gt;&lt;P&gt;Thank you for your valued assistance.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 12:24:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1174137#M77315</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-05-16T12:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1174191#M77317</link>
      <description>&lt;P&gt;Remove the check on graphics length and that will do it.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 15:12:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1174191#M77317</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-05-16T15:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1174985#M77359</link>
      <description>&lt;P&gt;Hi Rene&lt;/P&gt;&lt;P&gt;Thanks again for your help. I'm really new to this so your help is really appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for asking, I can't seem to edit it without it throwing an error. Which part do I need to remove?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 09:55:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1174985#M77359</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-05-18T09:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1175090#M77363</link>
      <description>&lt;LI-CODE lang="javascript"&gt;// change this
if (!view.graphics.length) {
  // check if layer where you clicked
  // with hitTest
  view.hitTest(evt).then(({results}) =&amp;gt; {
    if (results.length) {
      view.graphics.removeAll();
      view.graphics.add(graphic);
    }
  });
}

// to this
// check if layer where you clicked
// with hitTest
view.hitTest(evt).then(({results}) =&amp;gt; {
  if (results.length) {
    view.graphics.removeAll();
    view.graphics.add(graphic);
  }
});&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 18 May 2022 15:10:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1175090#M77363</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-05-18T15:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1175463#M77391</link>
      <description>&lt;P&gt;That's excellent and working well, thank you. I did try taking the top line out but I'd missed taking out the } right at the bottom and that clearly now was my error!&lt;/P&gt;&lt;P&gt;thank you so much for your patience, help and advice.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 08:12:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1175463#M77391</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-05-19T08:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1227053#M79175</link>
      <description>&lt;P&gt;Hi Rene,&lt;BR /&gt;&lt;BR /&gt;This has been working great, I hope you don't mind but I now have a further query with regards to this.&lt;BR /&gt;&lt;BR /&gt;I've been asked to add another layer to the map (the boundary layer) see this pen&amp;nbsp;&lt;A href="https://codepen.io/RFletERYC/full/mdKbQEo" target="_blank" rel="noopener"&gt;https://codepen.io/RFletERYC/full/mdKbQEo&lt;/A&gt;&amp;nbsp;&amp;nbsp;. When I add this layer the check on the graphics no longer works and I can drop a marker anywhere on the map again, rather than it being restricted to the streets layer.&lt;BR /&gt;&lt;BR /&gt;I note further up the comments you mention further checks such as layer id or title. This sounds like something I now need. How would I add one of those checks in please?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance. Ricky&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 14:58:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1227053#M79175</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-10-31T14:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Limit drop marker to feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1227063#M79176</link>
      <description>&lt;P&gt;You have a second hitTest in your code there, but aren't passing the options with the target layer in the include.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You do it the first hitTest.&lt;/P&gt;&lt;P&gt;I tested that in your codepen and it works just like before when you do that.&lt;/P&gt;&lt;P&gt;This sample does something similar.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/view-hittest/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/view-hittest/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For your example, this works ok.&amp;nbsp; But note that hitTest was updated at 4.24.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/release-notes/#mapview-and-sceneview-hittest-updates" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/release-notes/#mapview-and-sceneview-hittest-updates&lt;/A&gt;&lt;/P&gt;&lt;P&gt;So depending on how you are using the hitTest results, you may need to check the type like the snippet in the docs.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 15:32:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/limit-drop-marker-to-feature/m-p/1227063#M79176</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-10-31T15:32:21Z</dc:date>
    </item>
  </channel>
</rss>

