<?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 [ts] TileLayer Popups through sublayer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067488#M73464</link>
    <description>&lt;P&gt;I have a JS API 4.x application that needs to load arbitrary layers provided by users and display popups for these layers. Several of these layers are tile layers. Part of the app is a custom TypeScript widget to add these layers to the map but in it I'm having trouble setting the popup template. I want to use the feature service sublayer of the tile layer to access feature info and display the popups (&lt;A title="API Javascript 4.13 - TileLayer - PopupTemplate" href="https://community.esri.com/t5/arcgis-api-for-javascript/api-javascript-4-13-tilelayer-popuptemplate/td-p/642970" target="_blank" rel="noopener"&gt;like in this post&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;This code finds the fieldInfos for a layer (query the service for all its fields and returns them in an array of field objects with attributes of type, name and alias):&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 async _getFieldInfo(layer: LayerRef): Promise&amp;lt;Array&amp;lt;{fieldName: string, label: string}&amp;gt;&amp;gt; {
    ...
    const response = await request(fieldUrl, {query: {f: "json"}, responseType: "json"}).then(response =&amp;gt; response.data);
    const fields = response.fields;
     ...
    const fieldInfos: {fieldName: string, label: string}[] = [];
    response.type === "Feature Layer" ? fields.map((field: {name: string, type: string, alias: string}) =&amp;gt;
     ...
fieldInfos.push({fieldName: field.name, label: field.alias}) : null) : null;
    return fieldInfos;
  }&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then as part of my add layer function, I have:&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;      const fieldInfos = await this._getFieldInfo(layerRef);
      layer.when(function(layer: TileLayer){
        const featsSublayer = layer.findSublayerById(0)
        featsSublayer.load();
        featsSublayer.popupEnabled = true;
        featsSublayer.popupTemplate = {
          title: layerRef.name,
          content: [{
            type: "fields",
            fieldInfos: fieldInfos,
          }],
          outFields: ["*"]
        }
      });&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;P&gt;I'm getting a type error that prevents me from compiling on the fieldInfos variable in the content object of the sublayer popup template:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Type '{ type: "fields"; fieldInfos: { fieldName: string; label: string; }[]; }' is not assignable to type 'Content'.&lt;BR /&gt;Object literal may only specify known properties, and 'fieldInfos' does not exist in type 'Content'.&lt;/SPAN&gt;&lt;SPAN&gt;ts(2322)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Can anyone point me in the right direction to get my popup template working?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jun 2021 19:08:32 GMT</pubDate>
    <dc:creator>BenRomlein</dc:creator>
    <dc:date>2021-06-11T19:08:32Z</dc:date>
    <item>
      <title>[ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067488#M73464</link>
      <description>&lt;P&gt;I have a JS API 4.x application that needs to load arbitrary layers provided by users and display popups for these layers. Several of these layers are tile layers. Part of the app is a custom TypeScript widget to add these layers to the map but in it I'm having trouble setting the popup template. I want to use the feature service sublayer of the tile layer to access feature info and display the popups (&lt;A title="API Javascript 4.13 - TileLayer - PopupTemplate" href="https://community.esri.com/t5/arcgis-api-for-javascript/api-javascript-4-13-tilelayer-popuptemplate/td-p/642970" target="_blank" rel="noopener"&gt;like in this post&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;This code finds the fieldInfos for a layer (query the service for all its fields and returns them in an array of field objects with attributes of type, name and alias):&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 async _getFieldInfo(layer: LayerRef): Promise&amp;lt;Array&amp;lt;{fieldName: string, label: string}&amp;gt;&amp;gt; {
    ...
    const response = await request(fieldUrl, {query: {f: "json"}, responseType: "json"}).then(response =&amp;gt; response.data);
    const fields = response.fields;
     ...
    const fieldInfos: {fieldName: string, label: string}[] = [];
    response.type === "Feature Layer" ? fields.map((field: {name: string, type: string, alias: string}) =&amp;gt;
     ...
fieldInfos.push({fieldName: field.name, label: field.alias}) : null) : null;
    return fieldInfos;
  }&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then as part of my add layer function, I have:&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;      const fieldInfos = await this._getFieldInfo(layerRef);
      layer.when(function(layer: TileLayer){
        const featsSublayer = layer.findSublayerById(0)
        featsSublayer.load();
        featsSublayer.popupEnabled = true;
        featsSublayer.popupTemplate = {
          title: layerRef.name,
          content: [{
            type: "fields",
            fieldInfos: fieldInfos,
          }],
          outFields: ["*"]
        }
      });&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;P&gt;I'm getting a type error that prevents me from compiling on the fieldInfos variable in the content object of the sublayer popup template:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Type '{ type: "fields"; fieldInfos: { fieldName: string; label: string; }[]; }' is not assignable to type 'Content'.&lt;BR /&gt;Object literal may only specify known properties, and 'fieldInfos' does not exist in type 'Content'.&lt;/SPAN&gt;&lt;SPAN&gt;ts(2322)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Can anyone point me in the right direction to get my popup template working?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 19:08:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067488#M73464</guid>
      <dc:creator>BenRomlein</dc:creator>
      <dc:date>2021-06-11T19:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: [ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067495#M73465</link>
      <description>&lt;P&gt;This is likely an autocasting issue that happens occasionally when using TypeScript. I suggest explicitly declaring the FieldsContent class:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-content-FieldsContent.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-content-FieldsContent.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 19:18:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067495#M73465</guid>
      <dc:creator>BenElan</dc:creator>
      <dc:date>2021-06-11T19:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: [ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067613#M73467</link>
      <description>&lt;P&gt;Thanks for the reply. I tried this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      const fieldInfos = await this._getFieldInfo(layerRef);
      layer.when(function(layer: TileLayer){
        const featsSublayer: Sublayer = layer.findSublayerById(0)
        featsSublayer.load();
        featsSublayer.popupEnabled = true;
        const fieldContent = new FieldsContent({
          fieldInfos: fieldInfos
        })
        featsSublayer.popupTemplate = {
          title: layerRef.name,
          content: [fieldContent],
          outFields: ["*"]
        }
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I'm getting a type error on featsSublayer.popupTemplate now:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;Type '{ title: string; content: FieldsContent[]; outFields: string[]; }' is missing the following properties from type 'PopupTemplate': actions, expressionInfos, fieldInfos, lastEditInfoEnabled, and 16 more.&lt;/SPAN&gt;&lt;SPAN&gt;ts(2740)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;I also tried this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;      const fieldInfos = await this._getFieldInfo(layerRef);
      layer.when(function(layer: TileLayer){
        const featsSublayer = layer.findSublayerById(0)
        featsSublayer.load();
        featsSublayer.popupEnabled = true;
        featsSublayer.popupTemplate = {
          title: layerRef.name,
          content: new FieldsContent({
            fieldInfos: fieldInfos,
          }),
          outFields: ["*"]
        }
      });&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;and get this error on content:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Type 'FieldsContent' is not assignable to type 'string | Function | Promise&amp;lt;any&amp;gt; | Content[]'.&lt;BR /&gt;Type 'FieldsContent' is missing the following properties from type 'Content[]': length, pop, push, concat, and 26 more.ts(2322)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 11 Jun 2021 23:51:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067613#M73467</guid>
      <dc:creator>BenRomlein</dc:creator>
      <dc:date>2021-06-11T23:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: [ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067614#M73468</link>
      <description>&lt;P&gt;So the first snippet looks like it fixed the &lt;SPAN&gt;FieldsContent&amp;nbsp;&lt;/SPAN&gt;issue but there is a similar issue with the PopupTemplate. Can you try explicitly declaring the PopupTemplate class as well?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const fieldInfos = await this._getFieldInfo(layerRef);
      layer.when(function(layer: TileLayer){
        const featsSublayer: Sublayer = layer.findSublayerById(0)
        featsSublayer.load();
        featsSublayer.popupEnabled = true;
        const fieldContent = new FieldsContent({
          fieldInfos: fieldInfos
        })
        featsSublayer.popupTemplate = new PopupTemplate({
          title: layerRef.name,
          content: [fieldContent],
          outFields: ["*"]
        })
      });&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 11 Jun 2021 23:59:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067614#M73468</guid>
      <dc:creator>BenElan</dc:creator>
      <dc:date>2021-06-11T23:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: [ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067619#M73469</link>
      <description>&lt;P&gt;Thank you so much, this has resolved the type errors. However I'm still not getting my popups.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      const fieldInfos = await this._getFieldInfo(layerRef);
      layer.when(function(layer: TileLayer){
        const featsSublayer: Sublayer = layer.findSublayerById(0)
        featsSublayer.load();
        featsSublayer.popupEnabled = true;
        const fieldContent = new FieldsContent({
          fieldInfos: fieldInfos
        })
        featsSublayer.popupTemplate = new PopupTemplate({
          title: layerRef.name,
          content: [fieldContent],
          outFields: ["*"]
        });
      });
      this._addToMap([layer]);&lt;/LI-CODE&gt;&lt;P&gt;When I add a layer using this code and log map.layers to console, I can see my layer is there, but in its sublayers array, the sublayer shows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;loaded: false
popupEnabled: true
PopupTemplate: null&lt;/LI-CODE&gt;&lt;P&gt;I tried moving the sublayer.load, and popupTemplate declaration to happen after the layer is added to map, but it still doesn't seem to be loading or setting the popupTemplate.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jun 2021 00:18:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067619#M73469</guid>
      <dc:creator>BenRomlein</dc:creator>
      <dc:date>2021-06-12T00:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: [ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067733#M73474</link>
      <description>&lt;P&gt;Glad we fixed the type errors. If you can create a simplified sample that reproduces the popup functionality I can take a closer look. Just add the layer and popup on codepen or jsbin, no typescript needed. It sounds like it may now be an asynchronous issue somewhere.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Jun 2021 18:42:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067733#M73474</guid>
      <dc:creator>BenElan</dc:creator>
      <dc:date>2021-06-13T18:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: [ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067734#M73475</link>
      <description>&lt;P&gt;Before making the sample can you try adding the layer inside of the layer.when promise right after setting the popupTemplate?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      const fieldInfos = await this._getFieldInfo(layerRef);
      layer.when(function(layer: TileLayer){
        const featsSublayer: Sublayer = layer.findSublayerById(0)
        featsSublayer.load();
        featsSublayer.popupEnabled = true;
        const fieldContent = new FieldsContent({
          fieldInfos: fieldInfos
        })
        featsSublayer.popupTemplate = new PopupTemplate({
          title: layerRef.name,
          content: [fieldContent],
          outFields: ["*"]
        });
        this._addToMap([layer]);   // MOVE IT HERE
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Jun 2021 18:43:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067734#M73475</guid>
      <dc:creator>BenElan</dc:creator>
      <dc:date>2021-06-13T18:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: [ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067992#M73490</link>
      <description>&lt;P&gt;So I tried moving the load() and _addToMap calls around a bunch and none of the combinations resulted in the popups working. Most recently I tried putting everything within the when and addToMap after popupenabled with the same result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;  async add(layerRef: LayerRef): Promise&amp;lt;void&amp;gt; {
    layerRef.status = "active"
    if (layerRef.type === "TileLayer") {
      const layer =  new TileLayer({
        url: layerRef.url,
        id: layerRef.group + "-" + layerRef.name,
      });
      
      const fieldInfos = await this._getFieldInfo(layerRef);
      layer.when(function(layer: TileLayer){
        const featsSublayer: Sublayer = layer.findSublayerById(0)
        const fieldContent = new FieldsContent({
          fieldInfos: fieldInfos
        })
        featsSublayer.popupTemplate = new PopupTemplate({
          title: layerRef.name,
          content: [fieldContent],
          outFields: ["*"]
        });
        featsSublayer.load();
        featsSublayer.popupEnabled = true;
        this._addToMap([layer]);
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having a hard time setting up a pen, but I've got this: &lt;A href="https://codepen.io/broms/pen/dyvQBVN" target="_self"&gt;https://codepen.io/broms/pen/dyvQBVN&lt;/A&gt; that loads a TileLayer. I can't figure out why findSublayerById isn't working. I log the layer to console and I can see the sublayer there, but I'm getting an error setting popupTemplate that sublayer is undefined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: I've got the pen to where it's displaying popups but I'm having trouble setting the content of the popups. Also not sure how to duplicate this in my widget. I think it's like you said, some async stuff isn't lined up right. Do you have any tips on how to debug this? I'm really in the dark, I can't even get console logging to work within my viewmodel methods.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 18:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1067992#M73490</guid>
      <dc:creator>BenRomlein</dc:creator>
      <dc:date>2021-06-14T18:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: [ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1068652#M73503</link>
      <description>&lt;P&gt;I got the codepen sample to work by setting type to "fields" for the fieldContent:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fieldContent = {
    type: "fields",
    fieldInfos: [{
    fieldName: "NAME",
    label: "Name",
    type: "text"
    }, {
        fieldName: "CONDITION",
        label: "Condition"
    }]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;So at least we know that the functionality is possible. It does sound like an asynchronous issue which can be hard to debug, especially over a forum. Here is &lt;A href="https://codeburst.io/debugging-asynchronous-javascipt-ed993073aeb6" target="_self"&gt;an article&lt;/A&gt;&amp;nbsp;that has some recommendations for debugging asynchronous issues. Here is&lt;A href="https://developers.arcgis.com/javascript/latest/programming-patterns/#async-data" target="_self"&gt; ArcGIS JS API specific documentation about async programming patterns&lt;/A&gt;. If your code is somewhere public like github I can take a closer look as well.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 22:05:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1068652#M73503</guid>
      <dc:creator>BenElan</dc:creator>
      <dc:date>2021-06-15T22:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: [ts] TileLayer Popups through sublayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1068962#M73518</link>
      <description>&lt;P&gt;Thanks for the replies, I really appreciate your help.&lt;/P&gt;&lt;P&gt;I looked at it again today and it's working now. I'm not really sure which change did the trick and I also cleared my cache since working on it last, but whatever the case, I'm very pleased to have this bug in my app fixed, so thank you very much once again.&lt;BR /&gt;&lt;BR /&gt;For reference, this is the add layer code block in its current working form:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  async add(layerRef: LayerRef): Promise&amp;lt;void&amp;gt; {
    layerRef.status = "active"
    if (layerRef.type === "TileLayer") {
      const layer =  new TileLayer({
        url: layerRef.url,
        id: layerRef.group + "-" + layerRef.name,
      });
      
      const fieldInfos = await this._getFieldInfo(layerRef);
      
      layer.when(function(layer: TileLayer){
        
        const fieldContent = new FieldsContent({
          fieldInfos: fieldInfos
        });
        
        const featsSublayer: Sublayer = layer.findSublayerById(0)

        featsSublayer.popupTemplate = new PopupTemplate({
          title: layerRef.name,
          content: [fieldContent],
          outFields: ["*"]
        });

        featsSublayer.load();
        featsSublayer.popupEnabled = true;
      });

      this._addToMap([layer]);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 16:23:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/ts-tilelayer-popups-through-sublayer/m-p/1068962#M73518</guid>
      <dc:creator>BenRomlein</dc:creator>
      <dc:date>2021-06-16T16:23:15Z</dc:date>
    </item>
  </channel>
</rss>

