<?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: Remove all highlighted features from a layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1612988#M87113</link>
    <description>&lt;P&gt;Hey there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems like you are overwriting highlight handle each time a new feature is highlighted. As a result, when you call remove on the handle, it only removes the highlight from the most recently highlighted feature. To fix this,&amp;nbsp; you should store each highlight handle so they can all be removed later. You can do this by adding each handle to an array whenever a feature is highlighted, like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;highlight = layerView.highlight(result.features, {name: "temporary"});
hightlights.push(highlight);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Then, when you want to remove all highlights, loop through the array and call remove() on each handle:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;hightlights.forEach((h) =&amp;gt;{
  h.remove();
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This codepen shows how this works:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/OPPojdN?editors=1000" target="_blank" rel="noopener"&gt;https://codepen.io/U_B_U/pen/OPPojdN?editors=1000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;</description>
    <pubDate>Thu, 08 May 2025 21:09:50 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2025-05-08T21:09:50Z</dc:date>
    <item>
      <title>Remove all highlighted features from a layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1611783#M87089</link>
      <description>&lt;P&gt;I have a table that selects data and also highlights the data on the map. When I use the&amp;nbsp;&lt;STRONG&gt;highlightSelectRoom.remove ()&lt;/STRONG&gt;; it only removes the last highlighted object and not all of them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my code that selects the data in the map when the table&amp;nbsp; row is selected:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function zoomSingleRoom (id)
{
    require ([
        "esri/rest/query",
        "esri/rest/support/Query",
        "esri/layers/FeatureLayer"],
            function (query, Query, FeatureLayer)
            {
                console.log ("zoomRoom");
                view.whenLayerView (roomsOrgsLayer).then (function (layerView)
                {
                    var query = roomsOrgsLayer.createQuery ();
                    query.objectIds = [id];
                    query.where = "1=1";
                    roomsOrgsLayer.queryFeatures (query).then (function (results)
                    {
                        const features = results.features;
                         graphicsLayer = results.features;
                        highlightSelectRoom = layerView.highlight (results.features);
                    });
                });
            });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I call on the&amp;nbsp;highlightSelectRoom.remove () using a button and that also clears the selected rows in the table. Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 21:58:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1611783#M87089</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2025-05-05T21:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all highlighted features from a layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1612489#M87102</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition to calling&amp;nbsp;&lt;SPAN&gt;highlightSelectRoom.remove (), you also need to clear collection of &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#highlightIds" target="_self"&gt;highlightIds&lt;/A&gt; from the feature table. You can this in action in this sample -&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=highlight-features-by-geometry" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=highlight-features-by-geometry&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Essentially you need to add this line:&amp;nbsp;&lt;BR /&gt;table.highlightIds.removeAll();&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope this helps,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-Undral&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 May 2025 16:18:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1612489#M87102</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2025-05-07T16:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all highlighted features from a layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1612607#M87104</link>
      <description>&lt;P&gt;Thanks! I am not using a Feature table. I have some code that clears the slected rows.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will try the example and see if i can piece out what i need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank again!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 May 2025 20:30:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1612607#M87104</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2025-05-07T20:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all highlighted features from a layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1612907#M87108</link>
      <description>&lt;P&gt;I am confused about how to implement those examples since i do not use the FeatureTable. I have a jQuery&amp;nbsp;jqxGrid that i am using for my table. I have it working so that when ido click on a row it selects the FeatureLayer in the map. The problem is it only works to remove the last highlight selected.&amp;nbsp; I do not select them all at once but one at a time depending on what rows the user needs slecected to edit.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I gather the highlight ids that are being selected.&amp;nbsp; I found somehting like this but cannot get it to work:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function removeAllHighlights(layerView) {
  if (layerView &amp;amp;&amp;amp; layerView._highlightIds) {
    for (const id in layerView._highlightIds) {
      layerView.removeHighlight(id);
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have never dealt with the highlights before. So any help would be appreciated. Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 16:51:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1612907#M87108</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2025-05-08T16:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all highlighted features from a layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1612988#M87113</link>
      <description>&lt;P&gt;Hey there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems like you are overwriting highlight handle each time a new feature is highlighted. As a result, when you call remove on the handle, it only removes the highlight from the most recently highlighted feature. To fix this,&amp;nbsp; you should store each highlight handle so they can all be removed later. You can do this by adding each handle to an array whenever a feature is highlighted, like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;highlight = layerView.highlight(result.features, {name: "temporary"});
hightlights.push(highlight);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Then, when you want to remove all highlights, loop through the array and call remove() on each handle:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;hightlights.forEach((h) =&amp;gt;{
  h.remove();
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This codepen shows how this works:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/OPPojdN?editors=1000" target="_blank" rel="noopener"&gt;https://codepen.io/U_B_U/pen/OPPojdN?editors=1000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 21:09:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1612988#M87113</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2025-05-08T21:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all highlighted features from a layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1613395#M87125</link>
      <description>&lt;P&gt;Brilliant! That worked perfectly. Thank you so much for your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 May 2025 19:03:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-all-highlighted-features-from-a-layer/m-p/1613395#M87125</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2025-05-09T19:03:23Z</dc:date>
    </item>
  </channel>
</rss>

