<?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: Typescript error adding sublayers to MapImageLayer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-error-adding-sublayers-to-mapimagelayer/m-p/1260857#M80351</link>
    <description>&lt;P&gt;I'm not 100% positive, but I think that if you don't declare the sublayers in the MapImageLayer constructor, you need to use one of the Collection methods to define/add/modify the sublayers.&lt;/P&gt;&lt;P&gt;Collection methods:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#methods-summary" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#methods-summary&lt;/A&gt;&lt;/P&gt;&lt;P&gt;sublayers property:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#sublayers" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#sublayers&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Feb 2023 13:50:03 GMT</pubDate>
    <dc:creator>Noah-Sager</dc:creator>
    <dc:date>2023-02-23T13:50:03Z</dc:date>
    <item>
      <title>Typescript error adding sublayers to MapImageLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-error-adding-sublayers-to-mapimagelayer/m-p/1260750#M80338</link>
      <description>&lt;P&gt;I declare a mapimagelayer&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; const MPl = new MapImageLayer({
----
----&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I created an array of sublayers that need to be visilbe.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I added the sublayers index in an array&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;thearr.push({
            id: 1,
            visible: true},
           {
            id: 3,
            visible: true}
          );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I used:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;MPl.sublayers = thearr;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;but I got an&amp;nbsp; error&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LefterisKoumis_0-1677120416696.png" style="width: 612px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63483i19CA806B10C7137E/image-dimensions/612x17?v=v2" width="612" height="17" role="button" title="LefterisKoumis_0-1677120416696.png" alt="LefterisKoumis_0-1677120416696.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I used this script without using typescript i have no errors and it runs fine.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 02:48:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-error-adding-sublayers-to-mapimagelayer/m-p/1260750#M80338</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2023-02-23T02:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Typescript error adding sublayers to MapImageLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-error-adding-sublayers-to-mapimagelayer/m-p/1260857#M80351</link>
      <description>&lt;P&gt;I'm not 100% positive, but I think that if you don't declare the sublayers in the MapImageLayer constructor, you need to use one of the Collection methods to define/add/modify the sublayers.&lt;/P&gt;&lt;P&gt;Collection methods:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#methods-summary" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#methods-summary&lt;/A&gt;&lt;/P&gt;&lt;P&gt;sublayers property:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#sublayers" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#sublayers&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 13:50:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-error-adding-sublayers-to-mapimagelayer/m-p/1260857#M80351</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2023-02-23T13:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Typescript error adding sublayers to MapImageLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-error-adding-sublayers-to-mapimagelayer/m-p/1261277#M80366</link>
      <description>&lt;P&gt;Thank you. Looking at the documentation, it seems that in JS 4.x is more work&amp;nbsp; to define visible layers of a mapimagelayer. In JS 3.x&amp;nbsp; we could just write this.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="none"&gt;lyr.setVisibleLayers([1,2,3])&lt;/LI-CODE&gt;&lt;P&gt;I assume there is&amp;nbsp; no similar way of doing so in JS 4.x&amp;nbsp;&lt;/P&gt;&lt;P&gt;In a collection like&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;MPl.sublayers.push(item)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;where item or comma-separated list of items cannot be the sublayer id.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 01:54:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-error-adding-sublayers-to-mapimagelayer/m-p/1261277#M80366</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2023-02-24T01:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Typescript error adding sublayers to MapImageLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-error-adding-sublayers-to-mapimagelayer/m-p/1261464#M80377</link>
      <description>&lt;P&gt;Yes, there is an implementation difference between 3x and 4x. I would highly recommend looking at some 4x samples to get a feel for the difference. These two might be useful:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=layers-mapimagelayer-sublayers" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=layers-mapimagelayer-sublayers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=layers-mapimagelayer-definitionexpression" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=layers-mapimagelayer-definitionexpression&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 16:39:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-error-adding-sublayers-to-mapimagelayer/m-p/1261464#M80377</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2023-02-24T16:39:57Z</dc:date>
    </item>
  </channel>
</rss>

