<?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 Legend Not Rendered on Legend Widget in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-not-rendered-on-legend-widget/m-p/1045179#M72415</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using ES Module&amp;nbsp;@Anonymous User/core 4.18.1 for angular project, Legend with visual variable was not rendered properly.&lt;/P&gt;&lt;P&gt;The legend worked when doing in memory build. But when doing production build by issuing command&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ng build --configuration=production&lt;/LI-CODE&gt;&lt;P&gt;the legend didn't show and this error was shown on Chrome console.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="legend_error.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/10445i5BDE7F3CD94B116B/image-size/large?v=v2&amp;amp;px=999" role="button" title="legend_error.PNG" alt="legend_error.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step to reproduced the error&lt;/P&gt;&lt;P&gt;1) Create new project by using latest angular cli&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;ng new my-project
cd my-project
ng generate c map-test&lt;/LI-CODE&gt;&lt;P&gt;2) Add this simple code to add legend with visual variable&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    esriConfig.assetsPath = '/assets';
    const map = new Map({
      basemap: 'topo-vector'
    });

    const view = new MapView({
      map: map,
      container: 'map-container',
      center: [-84, 32],
      zoom: 5,
      constraints: {
        rotationEnabled: false
      }
    });

    const renderer: any = {
      type: 'simple',
      symbol: {
        type: 'simple-marker',
        size: '6px',
        outline: {
          width: '0px'
        }
      },
      visualVariables: [{
        type: 'color',
        valueExpressionTitle: `Legend Title`,
        field: 'some_field',
        stops: [{
          value: 0, color: '#ff0000'
        }, {
          value: 20000, color: '#0f0'
        }]
      }]
    };

    const legendLayer = new FeatureLayer({
      id: 'legend-id',
      source: [],
      fields: [{
        name: 'ObjectID',
        type: 'oid'
      }],
      opacity: 0.5,
      listMode: 'hide',
      objectIdField: 'ObjectID',
      geometryType: 'point',
      title: 'My legend',
      visible: true
    });
    legendLayer.renderer = renderer;

    map.add(legendLayer);

    const legends = new Legend({
      view: view
    });
    view.ui.add(legends, {
      position: 'bottom-right'
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; 3) run production build&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ng build --configuration=production&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS. I tested using latest angular version (11) as well as angular version 8&lt;/P&gt;</description>
    <pubDate>Thu, 08 Apr 2021 18:04:39 GMT</pubDate>
    <dc:creator>pegafal</dc:creator>
    <dc:date>2021-04-08T18:04:39Z</dc:date>
    <item>
      <title>Legend Not Rendered on Legend Widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-not-rendered-on-legend-widget/m-p/1045179#M72415</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using ES Module&amp;nbsp;@Anonymous User/core 4.18.1 for angular project, Legend with visual variable was not rendered properly.&lt;/P&gt;&lt;P&gt;The legend worked when doing in memory build. But when doing production build by issuing command&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ng build --configuration=production&lt;/LI-CODE&gt;&lt;P&gt;the legend didn't show and this error was shown on Chrome console.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="legend_error.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/10445i5BDE7F3CD94B116B/image-size/large?v=v2&amp;amp;px=999" role="button" title="legend_error.PNG" alt="legend_error.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step to reproduced the error&lt;/P&gt;&lt;P&gt;1) Create new project by using latest angular cli&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;ng new my-project
cd my-project
ng generate c map-test&lt;/LI-CODE&gt;&lt;P&gt;2) Add this simple code to add legend with visual variable&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    esriConfig.assetsPath = '/assets';
    const map = new Map({
      basemap: 'topo-vector'
    });

    const view = new MapView({
      map: map,
      container: 'map-container',
      center: [-84, 32],
      zoom: 5,
      constraints: {
        rotationEnabled: false
      }
    });

    const renderer: any = {
      type: 'simple',
      symbol: {
        type: 'simple-marker',
        size: '6px',
        outline: {
          width: '0px'
        }
      },
      visualVariables: [{
        type: 'color',
        valueExpressionTitle: `Legend Title`,
        field: 'some_field',
        stops: [{
          value: 0, color: '#ff0000'
        }, {
          value: 20000, color: '#0f0'
        }]
      }]
    };

    const legendLayer = new FeatureLayer({
      id: 'legend-id',
      source: [],
      fields: [{
        name: 'ObjectID',
        type: 'oid'
      }],
      opacity: 0.5,
      listMode: 'hide',
      objectIdField: 'ObjectID',
      geometryType: 'point',
      title: 'My legend',
      visible: true
    });
    legendLayer.renderer = renderer;

    map.add(legendLayer);

    const legends = new Legend({
      view: view
    });
    view.ui.add(legends, {
      position: 'bottom-right'
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; 3) run production build&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ng build --configuration=production&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS. I tested using latest angular version (11) as well as angular version 8&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 18:04:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-not-rendered-on-legend-widget/m-p/1045179#M72415</guid>
      <dc:creator>pegafal</dc:creator>
      <dc:date>2021-04-08T18:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Legend Not Rendered on Legend Widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-not-rendered-on-legend-widget/m-p/1045301#M72420</link>
      <description>&lt;P&gt;There's been a few bugs fixed that might be related to your issue. Try testing using 4.19-next build, which will be released to production in a few weeks. With 4.19 the assets will load via CDN by default, but you can still load them locally if needed. So comment out your assetsPath code when you try this upgrade:&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;npm i @Anonymous User/core@next&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, here's a working repo you can use to test:&amp;nbsp;&lt;A href="https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-angular-cli" target="_blank" rel="noopener"&gt;https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-angular-cli&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 23:36:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-not-rendered-on-legend-widget/m-p/1045301#M72420</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2021-04-08T23:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Legend Not Rendered on Legend Widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-not-rendered-on-legend-widget/m-p/1045467#M72430</link>
      <description>&lt;P&gt;Yes, 4.19 seems to fix this issue.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 15:56:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-not-rendered-on-legend-widget/m-p/1045467#M72430</guid>
      <dc:creator>pegafal</dc:creator>
      <dc:date>2021-04-09T15:56:41Z</dc:date>
    </item>
  </channel>
</rss>

