<?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: CSV Layer and Arcade in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/csv-layer-and-arcade/m-p/1185313#M77749</link>
    <description>&lt;P&gt;It's also a little bit clumsily worded.&amp;nbsp; Since the qualifier is phrased, "&lt;SPAN&gt;In ArcGIS Online, this only applies to feature service layers." it implies it works with layers other than feature services as long as you're outside of ArcGIS Online.&amp;nbsp; "This variable is only usable with feature service layers in ArcGIS Online" would have been a lot clearer.&amp;nbsp; Or explicitly&amp;nbsp;saying it does not work with in-memory layers would have also been good.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jun 2022 23:37:40 GMT</pubDate>
    <dc:creator>PhilipWeeks</dc:creator>
    <dc:date>2022-06-22T23:37:40Z</dc:date>
    <item>
      <title>CSV Layer and Arcade</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/csv-layer-and-arcade/m-p/1185303#M77747</link>
      <description>&lt;P&gt;I've been testing out Arcade expressions with the intent to create some graphs but I'm finding even simple math expressions I cannot get to work.&amp;nbsp; I could just be missing something basic but I'm not starting to wonder if maybe the CSVLayer is incompatible with certain bits of Arcade, specifically some global variables like $layer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cut down as much as possible and I still can't get a function like Count($layer) to work even though I can access individual features like $feature.year.&amp;nbsp; If I do Count([0,1]) the popup has a 2 like I'd expect.&amp;nbsp; I believe I've gotten Count($layer) to work with a portal item so I think it's something specific to CSVLayer.&amp;nbsp; Is there any work around or something I'm missing to get $layer to work with an in-memory CSVLayer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/&amp;gt;
    &amp;lt;title&amp;gt;Test&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
          html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    &amp;lt;/style&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.22/esri/themes/dark/main.css" /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.22/"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script&amp;gt;
require([
  "esri/Map",
  "esri/views/MapView",
  "esri/layers/CSVLayer",
  "esri/layers/Layer"
], (Map, MapView, CSVLayer, Layer) =&amp;gt; {

  const map = new Map({
    basemap: "dark-gray-vector"
  });
  const view = new MapView({
    map: map,
    container: "viewDiv",
  center: [-121.96, 37.87],
  scale: 2000
  });

  //var num = Count($layer);
  //var num = $feature.year;

  const popupTemplate = {  
  content: "{expression/test}",
    expressionInfos: [{
      name: "test",
      expression: `
      var num = Count($layer);
      return num;
      `
      }
    ]
  };

  const csv = `name|year|Longitude|latitude
  aspen|2020|-121.96|37.87
  birch|2018|-121.961|37.871`;

  const blob = new Blob([csv], {
    type: "plain/text"
  });

  let url = URL.createObjectURL(blob);

  const csvLayer = new CSVLayer({
    url: url,
    renderer: {
      type: "simple",  // autocasts as new SimpleRenderer()
      symbol: {
        type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
        size: 10,
        color: "red"
        }
      }
    });
    csvLayer.popupTemplate = popupTemplate;
    map.add(csvLayer);
  });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 23:21:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/csv-layer-and-arcade/m-p/1185303#M77747</guid>
      <dc:creator>PhilipWeeks</dc:creator>
      <dc:date>2022-06-22T23:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: CSV Layer and Arcade</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/csv-layer-and-arcade/m-p/1185309#M77748</link>
      <description>&lt;P&gt;Unfortunately, yes. $layer doesn't work for in-memory layers, like CSV, GeoJSON, etc. We document this in the description of $layer in the popup profile:&amp;nbsp;&lt;A href="https://developers.arcgis.com/arcade/guide/profiles/#popup" target="_blank"&gt;https://developers.arcgis.com/arcade/guide/profiles/#popup&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I admit it is a bit buried...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KristianEkenes_0-1655940506842.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/44102i159B9FBE43634689/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KristianEkenes_0-1655940506842.png" alt="KristianEkenes_0-1655940506842.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is a limitation I hope we can lift soon. Will take a bit of refactoring in the Arcade engine to add support for client-side layers.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 23:29:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/csv-layer-and-arcade/m-p/1185309#M77748</guid>
      <dc:creator>KristianEkenes</dc:creator>
      <dc:date>2022-06-22T23:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: CSV Layer and Arcade</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/csv-layer-and-arcade/m-p/1185313#M77749</link>
      <description>&lt;P&gt;It's also a little bit clumsily worded.&amp;nbsp; Since the qualifier is phrased, "&lt;SPAN&gt;In ArcGIS Online, this only applies to feature service layers." it implies it works with layers other than feature services as long as you're outside of ArcGIS Online.&amp;nbsp; "This variable is only usable with feature service layers in ArcGIS Online" would have been a lot clearer.&amp;nbsp; Or explicitly&amp;nbsp;saying it does not work with in-memory layers would have also been good.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 23:37:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/csv-layer-and-arcade/m-p/1185313#M77749</guid>
      <dc:creator>PhilipWeeks</dc:creator>
      <dc:date>2022-06-22T23:37:40Z</dc:date>
    </item>
  </channel>
</rss>

