<?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 remove graphics from a label layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-remove-graphics-from-a-label-layer/m-p/1172967#M77278</link>
    <description>&lt;P&gt;I am using 3.x and I need to start specifying that in my posts. Actually, I think I found the issue. I was actually clearing out the labelLayer graphics in another function and didn't realize, so just a stupid mistake. I now have access to the graphics! Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 11 May 2022 18:44:12 GMT</pubDate>
    <dc:creator>FranklinAlexander</dc:creator>
    <dc:date>2022-05-11T18:44:12Z</dc:date>
    <item>
      <title>How to remove graphics from a label layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-remove-graphics-from-a-label-layer/m-p/1172834#M77274</link>
      <description>&lt;P&gt;I have created a label layer and it is working fine except that I cannot remove a specific graphic from the layer. I can clear the graphics using layer.clear(), but I cannot seem to clear a single graphic from the layer because there don't appear to be any graphics in the layer even thought they are displaying on the map. I cannot find a graphics property, and the _graphicsVal property is empty []. Does anyone know what I am missing? The layer represents labels for a polygon layer and if I clear a particular polygon, I need to be able to clear the label for that polygon. Here is my code for how I am creating the label layer and adding the graphics:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// adding the label layer
 var layerDefHab = {
          "geometryType": "esriGeometryPoint",
          "fields": [{"name": "Label", "type": "esriFieldTypeString","alias": "Label"},
                     {"name": "Species", "type": "esriFieldTypeString", "alias:": "Name"}]
        }
        var fcHab = {
          layerDefinition: layerDefHab,
          featureSet: null
        };

        this._labelLayer = new FeatureLayer(fcHab, {
          id: "Result Labels",
          showLabels: true,
          outfields: "*",
          minScale: 5000
        });
        this.map.addLayer(this._labelLayer, 6);
        this._addNewLabelClass(this._labelLayer);

// adding graphics to the layer
array.forEach(lang.hitch(this, function(arr) {
          let text = arr[1] + ": " + arr[2] + arr[3];
          let attrs = arr[0].attributes;
          attrs.Label = text;
          let labelGraphic = new Graphic(arr[4], null, attrs, null);
          //console.log("label graphic ", labelGraphic);
          this._labelLayer.add(labelGraphic);          
        }))

//label class code
_addNewLabelClass: function(layer) {
        let symbolFont = this._getSymbolFont();
        let json = {
          "labelExpressionInfo": {"value": "{Label}"},
          "labelPlacement":"center-center",
          "minScale": "5000",
          "sizeInfo": {
            "field": "Label",
            "minSize": 8,
            "maxSize": 12,
            "minDataValue": 1,
            "maxDataValue": 50
          }
        };
        let lc = new LabelClass(json);
        lc.symbol = new TextSymbol({
          font: symbolFont,
          color: new Color([0,0,0]),
          haloColor: new Color([255,255,255]),
          haloSize: 2
        });
        layer.setLabelingInfo([ lc ]);
      },&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I am missing something obvious, so I appreciate any help.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 14:44:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-remove-graphics-from-a-label-layer/m-p/1172834#M77274</guid>
      <dc:creator>FranklinAlexander</dc:creator>
      <dc:date>2022-05-11T14:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove graphics from a label layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-remove-graphics-from-a-label-layer/m-p/1172867#M77275</link>
      <description>&lt;P&gt;In 4.x when you create a featurelayer (FL) from source graphics you need to query the FL to get its graphics. You are not able to just iterate of a graphics property like you use to in 3.x. To delete a feature you would need to use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits" target="_self"&gt;applyEdits&lt;/A&gt; on the featurelayer.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const queryParams = this._labelLayer.createQuery();
queryParams.where = 'your search criteria'
this._labelLayer.queryFeatures(queryParams).then(function(results){
  //now use the results that matched your criteria to delete that feature
  this._labelLayer.applyEdits({deleteFeatures:results.features});
});&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 11 May 2022 15:35:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-remove-graphics-from-a-label-layer/m-p/1172867#M77275</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2022-05-11T15:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove graphics from a label layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-remove-graphics-from-a-label-layer/m-p/1172967#M77278</link>
      <description>&lt;P&gt;I am using 3.x and I need to start specifying that in my posts. Actually, I think I found the issue. I was actually clearing out the labelLayer graphics in another function and didn't realize, so just a stupid mistake. I now have access to the graphics! Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 18:44:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-remove-graphics-from-a-label-layer/m-p/1172967#M77278</guid>
      <dc:creator>FranklinAlexander</dc:creator>
      <dc:date>2022-05-11T18:44:12Z</dc:date>
    </item>
  </channel>
</rss>

