<?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 Javascript 4.x legend refresh in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559421#M86082</link>
    <description>&lt;P&gt;I am using JS 4.30. I would like ot figure out how to get the legend to update the symbology of what is in the map when zoomed in. The legend for one of my layers has over 200 symbols. I have a fucntion to zoom into a specific building and floor. That building and floor does not have all 200 symbols it only has 10. I would like the legedn to update and show only the 10 symbols in the map.&lt;/P&gt;&lt;P&gt;The print funtion does this see attached.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help Thank you!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2024 22:51:12 GMT</pubDate>
    <dc:creator>Mr_Kirkwood</dc:creator>
    <dc:date>2024-11-15T22:51:12Z</dc:date>
    <item>
      <title>Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559421#M86082</link>
      <description>&lt;P&gt;I am using JS 4.30. I would like ot figure out how to get the legend to update the symbology of what is in the map when zoomed in. The legend for one of my layers has over 200 symbols. I have a fucntion to zoom into a specific building and floor. That building and floor does not have all 200 symbols it only has 10. I would like the legedn to update and show only the 10 symbols in the map.&lt;/P&gt;&lt;P&gt;The print funtion does this see attached.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 22:51:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559421#M86082</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-11-15T22:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559444#M86083</link>
      <description>&lt;P&gt;You could use something like this, which appears to do the trick.&amp;nbsp; Basically, after every time the layer redraws, a new renderer is created with only the symbology visible in the view, and then assigned to the layer.&amp;nbsp; Just pass in references to your &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html" target="_self"&gt;featureLayer&lt;/A&gt; and &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html" target="_self"&gt;view&lt;/A&gt; and it does the rest:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function manageDynamicSymbology(featureLayer, view) {
	featureLayer.when(function() {
		view.whenLayerView(featureLayer).then(function(layerView) {
			var originalRenderer = featureLayer.renderer;
			var ignoreRendererSet = false;

			layerView.watch("updating", function(newValue, oldValue, propertyName, target) {
				if ((!newValue) &amp;amp;&amp;amp; (oldValue)) {
				  if (ignoreRendererSet)
				    ignoreRendererSet = false;
				  else {
				    ignoreRendererSet = true;

				    var query = layerView.createQuery();
				    query.geometry = view.extent;
  
  					layerView.queryFeatures(query).then(function(featureSet) {
  						if (featureSet.features.length === 0)
  							featureLayer.renderer = originalRenderer;
  						else {
  							var promises = [];
  
  							featureSet.features.forEach(function(feature) {
  								promises.push(originalRenderer.getUniqueValueInfo(feature));
  							});
  
  							Promise.all(promises).then(function(infos) {
  								var uniqueValueInfos = [];
  								var defaultSymbol = null;
  								var defaultLabel = null;
  
  								infos.forEach(function(uniqueValueInfo) {
  								    if (!uniqueValueInfo) {
  								      if (defaultSymbol === null) {
  								        defaultSymbol = originalRenderer.defaultSymbol.clone();
  								        defaultLabel = originalRenderer.defaultLabel;
  								      }
  								    } else if (!uniqueValueInfos.includes(uniqueValueInfo))
  								      uniqueValueInfos.push(uniqueValueInfo);
  								});

  							  var newRenderer = featureLayer.renderer.clone();
  							  newRenderer.uniqueValueInfos = uniqueValueInfos;
  							  newRenderer.defaultSymbol = defaultSymbol;
  							  newRenderer.defaultLabel = defaultLabel;

  							  featureLayer.renderer = newRenderer;
  							});
  						}
  					}, function(e) {
  						featureLayer.renderer = originalRenderer;
  					});
				  }
				}
			});
		});
	});
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 00:25:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559444#M86083</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-11-16T00:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559676#M86085</link>
      <description>&lt;P&gt;Joel,&lt;/P&gt;&lt;P&gt;Thank you for this code. I will figure out how to implement it and get back to you with my results.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 15:07:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559676#M86085</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-11-18T15:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559740#M86086</link>
      <description>&lt;P&gt;Joel,&lt;/P&gt;&lt;P&gt;This worked perfectly. I really appreciate your help on this! Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 16:38:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559740#M86086</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-11-18T16:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559741#M86087</link>
      <description>&lt;P&gt;p.s. is there anyway to make the legend display in ascending order?&amp;nbsp; The values are randomly in order.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 16:39:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559741#M86087</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-11-18T16:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559778#M86088</link>
      <description>&lt;P&gt;I believe that if you replace line 43 with this, it will maintain their original order:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;newRenderer.uniqueValueInfos = uniqueValueInfos.sort(function(a, b) {return originalRenderer.uniqueValueInfos.indexOf(a) - originalRenderer.uniqueValueInfos.indexOf(b);});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise, you can implement &lt;A href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort" target="_self"&gt;the sort function&lt;/A&gt; according to how you want.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 17:31:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559778#M86088</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-11-18T17:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559786#M86089</link>
      <description>&lt;P&gt;Once again you have solved the answer perfectly. Thank you again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 17:38:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1559786#M86089</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-11-18T17:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562642#M86133</link>
      <description>&lt;P&gt;Joel,&lt;/P&gt;&lt;P&gt;Is there a way to achieve this for JS 3.x? I still have some legacy apps that I would like to maintain until I get the JS 4.x apps up and running.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for all of your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2024 14:15:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562642#M86133</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-11-26T14:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562732#M86135</link>
      <description>&lt;P&gt;This seems to do it:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function manageDynamicSymbology(featureLayer, map) {
	if (featureLayer.loaded)
		manageDynamicSymbology2(featureLayer, map);
	else {
		featureLayer.on("load", function() {
			manageDynamicSymbology2(featureLayer, map);
		});
	}
}

function manageDynamicSymbology2(featureLayer, map) {
	require(["esri/renderers/jsonUtils", "esri/symbols/jsonUtils"], function(rendererJsonUtils, symbolJsonUtils) {
		var originalRenderer = featureLayer.renderer;

		featureLayer.on("update-end", function() {
			var infos = [];

			featureLayer.graphics.forEach(function(graphic) {
				if (map.extent.intersects(graphic.geometry)) {
					var info = originalRenderer.getUniqueValueInfo(graphic);

					if (info)
						infos.push(info);
				}
			});

			var uniqueValueInfos = [];
			var defaultSymbol = null;
  			var defaultLabel = null;

			infos.forEach(function(uniqueValueInfo) {
				if (!uniqueValueInfo) {
					if ((defaultSymbol === null) &amp;amp;&amp;amp; (originalRenderer.defaultSymbol)) {
						defaultSymbol = symbolJsonUtils.fromJson(originalRenderer.defaultSymbol.toJson());
						defaultLabel = originalRenderer.defaultLabel;
					}
				} else if (!uniqueValueInfos.includes(uniqueValueInfo))
					uniqueValueInfos.push(uniqueValueInfo);
			});

			var newRenderer = rendererJsonUtils.fromJson(featureLayer.renderer.toJson());
			newRenderer.infos = uniqueValueInfos.sort(function(a, b) {return originalRenderer.infos.indexOf(a) - originalRenderer.infos.indexOf(b);});
			newRenderer.defaultSymbol = defaultSymbol;
			newRenderer.defaultLabel = defaultLabel;

			featureLayer.setRenderer(newRenderer);
		});
	});
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 26 Nov 2024 17:39:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562732#M86135</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-11-26T17:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562783#M86137</link>
      <description>&lt;P&gt;That works to a degree. For my zoomTo function, I have to set the Feature layer to these settings:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;     roomUseLayer = new FeatureLayer (urlRoomsUse, {
                    mode: FeatureLayer.MODE_SELECTION,
                    id: 'roomUseLayer',
                    visible: true,
                    outFields: ["*"],
                    opacity: 0.6,
                })&lt;/LI-CODE&gt;&lt;P&gt;Using&amp;nbsp;FeatureLayer.MODE_SELECTION does not update the legend. If i use&amp;nbsp; FeatureLayer.MODE_ONDEMAND the legend updates but all the floors draw not just the one being&amp;nbsp; zoomed into.&amp;nbsp; Not sure what the best approach is for this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2024 19:46:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562783#M86137</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-11-26T19:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562800#M86138</link>
      <description>&lt;P&gt;I see...yes, this approach will not work with MODE_SELECTION since the graphics array won't be populated unless something is selected, and even then, only the selected features will be present in the graphics array.&lt;/P&gt;&lt;P&gt;Based on the info provided, a suitable workaround might be to use a MODE_ONDEMAND layer, with the definition expression set to only show rooms for the current floor.&amp;nbsp; See also &lt;A href="https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#getdefinitionexpression" target="_self"&gt;getDefinitionExpression&lt;/A&gt; and&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#setdefinitionexpression" target="_self"&gt;setDefinitionExpression&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2024 20:02:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562800#M86138</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-11-26T20:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562840#M86139</link>
      <description>&lt;P data-unlink="true"&gt;Thank you for your help. This gives me a good start.&amp;nbsp; Here is my zoomTo function that I need to figure out the&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#getdefinitionexpression" target="_self" rel="nofollow noopener noreferrer"&gt;getDefinitionExpression&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;and&amp;nbsp;&lt;/SPAN&gt;setDefinitionExpression.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;unction zoomRoomUse (ids)
{
    require ([
        "esri/tasks/query",
        "esri/geometry/Extent",
        "esri/layers/FeatureLayer"
    ],
            function (Query, Extent, FeatureLayer)
            {
                console.log ("zoomRoomUse");
                var query = new Query ();
                query.objectIds = ids;
                roomUseLayer.setDefinitionExpression = query.objectIds
                query.where = roomUseLayer.setDefinitionExpression;
                console.log ("zoomRoomUse + id" + ids)
                 console.log ("zoomRoomUse + ids" + roomUseLayer.setDefinitionExpression)
                roomUseLayer.selectFeatures (query, FeatureLayer.SELECTION_NEW, function (features)
                {
                    var newExtent = new Extent ();
                    newExtent = features[0].geometry.getExtent ();
                    for (var k = 0; k &amp;lt; features.length; k++) {
                        newExtent = newExtent.union (features[k].geometry.getExtent ().expand (15));
                    }
                    manageDynamicSymbology (roomUseLayer, map)
                    labelRoom ();
                });
            });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2024 21:01:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562840#M86139</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-11-26T21:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562871#M86141</link>
      <description>&lt;P&gt;Instead of:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;roomUseLayer.setDefinitionExpression = query.objectIds&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You probably want:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;roomUseLayer.setDefinitionExpression(roomUserLayer.objectIdField + " IN(" + ids.join(",") + ")");&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 26 Nov 2024 22:20:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562871#M86141</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-11-26T22:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562875#M86142</link>
      <description>&lt;P&gt;Thanks! I will test this out in the morning.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2024 22:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1562875#M86142</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-11-26T22:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575138#M86369</link>
      <description>&lt;P&gt;Joel,&lt;/P&gt;&lt;P&gt;I have noticed that the code above gives me this error:&lt;/P&gt;&lt;P&gt;Uncaught (in promise) TypeError: Cannot read properties of null (reading 'clone')&lt;/P&gt;&lt;P&gt;Line 35:&lt;/P&gt;&lt;P&gt;" defaultSymbol = originalRenderer.defaultSymbol.clone ();"&lt;/P&gt;&lt;P&gt;The error continues to infinity sometimes. It happens when i use the zoom to feature and sometimes it happens when i click identify on the map. I am not sure what is happening. The zoom fucntion looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function zoomRoomUse (ids)
{
    require ([
        "esri/rest/query",
        "esri/rest/support/Query",
        "esri/layers/FeatureLayer",
        "esri/views/layers/LayerView"
    ],
            function (query, Query, FeatureLayer, LayerView)
            {
                roomsUseLayer.definitionExpression = roomsUseLayer.objectIdField + " IN(" + ids.join (",") + ")";
//                console.log (roomsUseLayer.definitionExpression)
                view.whenLayerView (roomsUseLayer).then (function (layerView)
                {
                    var query = roomsUseLayer.createQuery ();
                    query.objectIds = [ids];
                    query.where = roomsUseLayer.definitionExpression;
                    roomsUseLayer.queryFeatures (query).then (function (results)
                    {
                        const features = results.features;
                        var geometry = features[0].geometry.extent.clone ();
                        for (var k = 0; k &amp;lt; features.length; k++) {
                            geometry = geometry.union (features[k].geometry.extent.clone ());
                            view.goTo (geometry).then (function ()
                            {
                                roomsUseLayer.visible = true;
                                manageDynamicSymbology (roomsUseLayer, view);
                            }).catch (function (error)
                            {
                                if (error.name != "view:goto-interrupted") {
                                    console.error (error);
                                } else {
                                    console.log ("Drawing");
                                }
                            });
                        }
                    });
                });
            });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 22:02:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575138#M86369</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2025-01-13T22:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575158#M86370</link>
      <description>&lt;P&gt;It appears this will happen in cases where (1) a value exists, but no symbol has been defined for it, and (2) there is no default symbol defined.&amp;nbsp; In this case, the feature wouldn't be rendered at all.&amp;nbsp; To avoid the error, you could change the statement on line 34 from:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (defaultSymbol === null) {&lt;/LI-CODE&gt;&lt;P&gt;to&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if ((defaultSymbol === null) &amp;amp;&amp;amp; (originalRenderer.defaultSymbol)) {&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Jan 2025 22:34:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575158#M86370</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2025-01-13T22:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575166#M86372</link>
      <description>&lt;P&gt;Joel,&lt;/P&gt;&lt;P&gt;There is no error now, but the layer is flickering on and off.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 22:51:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575166#M86372</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2025-01-13T22:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575172#M86373</link>
      <description>&lt;P&gt;Here is the full code:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function manageDynamicSymbology (featureLayer, view)
{
    featureLayer.when (function ()
    {
        view.whenLayerView (featureLayer).then (function (layerView)
        {
            var originalRenderer = featureLayer.renderer;
            var ignoreRendererSet = false;

            layerView.watch ("updating", function (newValue, oldValue, propertyName, target)
            {
                if ((!newValue) &amp;amp;&amp;amp; (oldValue)) {
                    if (ignoreRendererSet)
                        ignoreRendererSet = false;
                    else {
                        ignoreRendererSet = true;

                        var query = layerView.createQuery ();
                        query.geometry = view.extent;

                        layerView.queryFeatures (query).then (function (featureSet)
                        {
                            if (featureSet.features.length === 0)
                                featureLayer.renderer = originalRenderer;
                            else {
                                var promises = [];

                                featureSet.features.forEach (function (feature)
                                {
                                    promises.push (originalRenderer.getUniqueValueInfo (feature));
                                });

                                Promise.all (promises).then (function (infos)
                                {
                                    var uniqueValueInfos = [];
                                    var defaultSymbol = null;
                                    var defaultLabel = null;

                                    infos.forEach (function (uniqueValueInfo)
                                    {
                                        if (!uniqueValueInfo) {
                                            if ((defaultSymbol === null) &amp;amp;&amp;amp; (originalRenderer.defaultSymbol)) {
                                                defaultSymbol = originalRenderer.defaultSymbol.clone ();
                                                defaultLabel = originalRenderer.defaultLabel;
                                            }
                                        } else if (!uniqueValueInfos.includes (uniqueValueInfo))
                                            uniqueValueInfos.push (uniqueValueInfo);
                                    });

                                    var newRenderer = featureLayer.renderer.clone ();
                                    newRenderer.uniqueValueInfos = uniqueValueInfos.sort (function (a, b)
                                    {
                                        return originalRenderer.uniqueValueInfos.indexOf (a) - originalRenderer.uniqueValueInfos.indexOf (b);
                                    });
                                    newRenderer.defaultSymbol = defaultSymbol;
                                    newRenderer.defaultLabel = defaultLabel;

                                    featureLayer.renderer = newRenderer;
                                });
                            }
                        }, function (e)
                        {
                            featureLayer.renderer = originalRenderer;
                        });
                    }
                }
            });
        });
    });
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Jan 2025 23:04:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575172#M86373</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2025-01-13T23:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575201#M86374</link>
      <description>&lt;P&gt;There is a possibility of an infinite loop occurring since setting the renderer will result in the "updating" property being set, and when the "updating" property is set to false, the process starts over again.&amp;nbsp; However, that's what the "ignoreRendererSet" variable exists to prevent, and I don't see any immediate problem with it not doing its job.&amp;nbsp; I would recommend using the browser's developer tools to add some breakpoints and step through the code to help determine where the infinite loop is occurring.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 02:06:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575201#M86374</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2025-01-14T02:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript 4.x legend refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575774#M86385</link>
      <description>&lt;P&gt;Joel,&lt;/P&gt;&lt;P&gt;the code loop seems to be around this line:&lt;/P&gt;&lt;P&gt;infos.forEach (function (uniqueValueInfo)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will work for a few buildings then will start to loop.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 14:11:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-4-x-legend-refresh/m-p/1575774#M86385</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2025-01-15T14:11:39Z</dc:date>
    </item>
  </channel>
</rss>

