<?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 How to update UniqueValueRenderer with new symbols in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-update-uniquevaluerenderer-with-new-symbols/m-p/1116473#M75272</link>
    <description>&lt;P&gt;Hello all, I am wondering if it's possible to update UniqueValueRenderer after it has been initialized with symbols and their corresponding fieldNames. My application creates a GeoJSONLayer, which is assigned a UniqueValueRenderer that contains all the symbol information for the displayed geoFeatures. However, I'd like to update some of the symbols for the rendered geoFeatures if a user hovers over it or selects it.&lt;/P&gt;&lt;P&gt;The only case where I have been able to update a symbol within the geojson layer is when the UniqueValueRenderer already contains the fieldName, symbol pair. Is it possible to add a new symbol to the UniqueValueRenderer and refresh it so that a specific geoFeature's symbol gets updated? I've tried reassigning the &lt;STRONG&gt;renderer &lt;/STRONG&gt;property of GeoJSONLayer after modifying the UVR, but the symbol that's supposed to change style just disappears.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  private updateFeatures(results, layer: GeoJSONLayer)
  {
    if (results.length &amp;gt;  0)
    {
      const updatedGraphics = {
        updateFeatures: []
      }

      results.forEach((feature) =&amp;gt; {

        feature.attributes[UNIQUE_VALUE_RENDERER_FIELD] = "drawing"; // set new style
        updatedGraphics.updateFeatures.push(feature); // update geojson feature
      })

      let symbol = {
        type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
        style: "square",
        color: "blue",
        size: "8px",  // pixels
        outline: {  // autocasts as new SimpleLineSymbol()
          color: [ 255, 255, 0 ],
          width: 3  // points
        }
      };

      const renderer = layer.renderer as UniqueValueRenderer;
      renderer.addUniqueValueInfo("drawing", symbol); // assign new symbol to new style

      if (updatedGraphics.updateFeatures.length &amp;gt; 0){
        this.applyEditsToGeoJSON(updatedGraphics, layer); // apply changes to feature
      }

    }
  }

  private applyEditsToGeoJSON(params, layer: GeoJSONLayer)
  {
    layer.applyEdits(params)
      .then((result) =&amp;gt; {
        result.updateFeatureResults.forEach((updatedFeature) =&amp;gt; {
          console.log('feature with id ' + updatedFeature.objectId + ' updated');
        })
      })
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Fri, 12 Nov 2021 23:59:11 GMT</pubDate>
    <dc:creator>ironmaskito</dc:creator>
    <dc:date>2021-11-12T23:59:11Z</dc:date>
    <item>
      <title>How to update UniqueValueRenderer with new symbols</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-update-uniquevaluerenderer-with-new-symbols/m-p/1116473#M75272</link>
      <description>&lt;P&gt;Hello all, I am wondering if it's possible to update UniqueValueRenderer after it has been initialized with symbols and their corresponding fieldNames. My application creates a GeoJSONLayer, which is assigned a UniqueValueRenderer that contains all the symbol information for the displayed geoFeatures. However, I'd like to update some of the symbols for the rendered geoFeatures if a user hovers over it or selects it.&lt;/P&gt;&lt;P&gt;The only case where I have been able to update a symbol within the geojson layer is when the UniqueValueRenderer already contains the fieldName, symbol pair. Is it possible to add a new symbol to the UniqueValueRenderer and refresh it so that a specific geoFeature's symbol gets updated? I've tried reassigning the &lt;STRONG&gt;renderer &lt;/STRONG&gt;property of GeoJSONLayer after modifying the UVR, but the symbol that's supposed to change style just disappears.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  private updateFeatures(results, layer: GeoJSONLayer)
  {
    if (results.length &amp;gt;  0)
    {
      const updatedGraphics = {
        updateFeatures: []
      }

      results.forEach((feature) =&amp;gt; {

        feature.attributes[UNIQUE_VALUE_RENDERER_FIELD] = "drawing"; // set new style
        updatedGraphics.updateFeatures.push(feature); // update geojson feature
      })

      let symbol = {
        type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
        style: "square",
        color: "blue",
        size: "8px",  // pixels
        outline: {  // autocasts as new SimpleLineSymbol()
          color: [ 255, 255, 0 ],
          width: 3  // points
        }
      };

      const renderer = layer.renderer as UniqueValueRenderer;
      renderer.addUniqueValueInfo("drawing", symbol); // assign new symbol to new style

      if (updatedGraphics.updateFeatures.length &amp;gt; 0){
        this.applyEditsToGeoJSON(updatedGraphics, layer); // apply changes to feature
      }

    }
  }

  private applyEditsToGeoJSON(params, layer: GeoJSONLayer)
  {
    layer.applyEdits(params)
      .then((result) =&amp;gt; {
        result.updateFeatureResults.forEach((updatedFeature) =&amp;gt; {
          console.log('feature with id ' + updatedFeature.objectId + ' updated');
        })
      })
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 12 Nov 2021 23:59:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-update-uniquevaluerenderer-with-new-symbols/m-p/1116473#M75272</guid>
      <dc:creator>ironmaskito</dc:creator>
      <dc:date>2021-11-12T23:59:11Z</dc:date>
    </item>
  </channel>
</rss>

