<?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: 3.41 Arcade Labeling Bug in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-31-arcade-labeling-bug/m-p/1603812#M86844</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6522"&gt;@JoelBennett&lt;/a&gt;,&amp;nbsp;thanks for posting your question here. Would you be able to share a simplified app that reproduces the error you shared? I tried to create an app with a labeled FeatureLayer using the Round function in Arcade:&amp;nbsp;&lt;A href="https://codepen.io/noash/pen/Byaedpe?editors=1000" target="_blank"&gt;https://codepen.io/noash/pen/Byaedpe?editors=1000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The FeatureLayer is from a MapServer that was published with wkid: 4269 spatial reference. However, the MapServer was not published with labels, so perhaps that is the key.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Apr 2025 15:40:38 GMT</pubDate>
    <dc:creator>Noah-Sager</dc:creator>
    <dc:date>2025-04-08T15:40:38Z</dc:date>
    <item>
      <title>4.31 Arcade Labeling Bug</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-31-arcade-labeling-bug/m-p/1603535#M86840</link>
      <description>&lt;DIV&gt;I have a map service published to ArcGIS Server whose spatial reference is WGS 84 UTM Zone 6N (WKID 32606).&amp;nbsp; One of the layers in the service has labeling information defined, and the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpressionInfo" target="_self"&gt;labelExpressionInfo.expression&lt;/A&gt; is set to: &lt;STRONG&gt;Round(Length(Geometry($feature),"feet"),2)&lt;/STRONG&gt;.&amp;nbsp; I load this layer into a map as a 2D &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html" target="_self"&gt;FeatureLayer&lt;/A&gt;.&amp;nbsp; The spatial reference of the map is Web Mercator (WKID 3857).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The data being retrieved from the server is returned by ArcGIS Server projected into Web Mercator (WKID 3857).&amp;nbsp; Nonetheless, labels do not show up, and the following error appears in the console:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#FF0000"&gt;Cannot work with geometry in this spatial reference. It is different to the execution spatial reference&lt;/FONT&gt;.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This should not be happening because the data queried from the service is already in the Web Mercator projection.&amp;nbsp; The problem is that the API, when processing the FeatureSets returned from the server, assigns the layer's spatial reference (WKID 32606) to the data, even though the coordinates are Web Mercator.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The most convenient place I've found to insert a fix for this is in the esri.views.2d.layers.features.support.FeatureSetReaderJSON module, in the "fromFeatureSet" method.&amp;nbsp; The published implementation looks like this:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;LI-CODE lang="javascript"&gt;static fromFeatureSet(a, f) {
	a = q.convertFromFeatureSet(a, f.objectIdField);
	return l.fromOptimizedFeatureSet(a, f)
}&lt;/LI-CODE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The "a" parameter is the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html" target="_self"&gt;FeatureSet&lt;/A&gt; returned from the query, still in JSON format.&amp;nbsp; The "f" parameter is an object containing various settings from the layer, including the spatial reference.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Basically, I clone the "f" object, and set its spatial reference to the same as the FeatureSet:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;LI-CODE lang="javascript"&gt;static fromFeatureSet(a, f) {
	var g = {};
	Object.getOwnPropertyNames(f).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(f))).forEach(function(h) {
		if (typeof f[h] != "function")
			g[h] = f[h];
	});
	if (a.spatialReference)
		g.spatialReference = f.spatialReference.constructor.fromJSON(a.spatialReference);
	f = g;
	a = q.convertFromFeatureSet(a, f.objectIdField);
	return l.fromOptimizedFeatureSet(a, f)
}&lt;/LI-CODE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;As can be seen, I've added lines 2-9, and everything else is the same.&amp;nbsp; With this fix in place, no errors occur and the labels show up properly.&amp;nbsp; I was using 4.31 for this, but other versions may be affected as well.&lt;/DIV&gt;</description>
      <pubDate>Wed, 09 Apr 2025 18:01:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-31-arcade-labeling-bug/m-p/1603535#M86840</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2025-04-09T18:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: 3.41 Arcade Labeling Bug</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-31-arcade-labeling-bug/m-p/1603812#M86844</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6522"&gt;@JoelBennett&lt;/a&gt;,&amp;nbsp;thanks for posting your question here. Would you be able to share a simplified app that reproduces the error you shared? I tried to create an app with a labeled FeatureLayer using the Round function in Arcade:&amp;nbsp;&lt;A href="https://codepen.io/noash/pen/Byaedpe?editors=1000" target="_blank"&gt;https://codepen.io/noash/pen/Byaedpe?editors=1000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The FeatureLayer is from a MapServer that was published with wkid: 4269 spatial reference. However, the MapServer was not published with labels, so perhaps that is the key.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2025 15:40:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-31-arcade-labeling-bug/m-p/1603812#M86844</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2025-04-08T15:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: 3.41 Arcade Labeling Bug</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-31-arcade-labeling-bug/m-p/1603843#M86848</link>
      <description>&lt;P&gt;Aloha Noah, thanks for following up.&amp;nbsp; Your example uses the Shape_Length field, so doesn't exhibit the problem, since that's a numerical attribute.&amp;nbsp; The problem I'm running into appears to happen when using the&amp;nbsp;&lt;A href="https://developers.arcgis.com/arcade/function-reference/geometry_functions/#geometry" target="_self"&gt;Geometry&lt;/A&gt; function.&amp;nbsp; In your example, I changed the expression to:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;expression: "Round(Length(Geometry($feature),\"feet\"),2)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In doing so, I was surprised to find it working.&amp;nbsp; I then changed line 22 to use version 4.31, and the labels stopped appearing, although there weren't any errors in the console.&amp;nbsp; It appears that perhaps this may have been fixed in 4.32.&amp;nbsp; I haven't started testing with 4.32 yet, but plan to later this week or next.&amp;nbsp; When I do, I'll try this issue out and see what happens.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2025 16:45:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-31-arcade-labeling-bug/m-p/1603843#M86848</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2025-04-08T16:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: 3.41 Arcade Labeling Bug</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-31-arcade-labeling-bug/m-p/1609028#M87025</link>
      <description>&lt;P&gt;After testing, I've concluded this was fixed in 4.32 since the situation described above now works without having to apply any fixes.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 19:12:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-31-arcade-labeling-bug/m-p/1609028#M87025</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2025-04-24T19:12:17Z</dc:date>
    </item>
  </channel>
</rss>

