<?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 ESRI JS 4.x TileLayer() Capabilities Property in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-4-x-tilelayer-capabilities-property/m-p/1271443#M80851</link>
    <description>&lt;P&gt;I have a cached map image service that I am calling in a JS web app (JS 4.x) using TileLayer(). The cached service has about 20 sublayers in it. My goal is to allow end-users to toggle each sublayer's visibility. According to documentation (&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html&lt;/A&gt;) you can access "&lt;SPAN&gt;supportsSublayerVisibility" via the Capabilities property. I have set that parameter to "true." When I try and toggle the visibility, the "eye" changes on click, but the data in the map is not affected (i.e. the visibility does not actually change).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here is an image of my LayerList()&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="moremeowbell_0-1679677565140.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66215i340770221D46EA05/image-size/medium?v=v2&amp;amp;px=400" role="button" title="moremeowbell_0-1679677565140.png" alt="moremeowbell_0-1679677565140.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the portion of my code that touches the dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let layer = new TileLayer({
  portalItem: {
    id: "PORTAL ID",
  }
});

layer.load()
.then(function(){
  layer.capabilities.exportMap.supportsSublayerVisibility = true;
  layer.capabilities.exportMap.supportsDynamicLayers = true;
  layer.capabilities.exportMap.supportsSublayersChanges = true;
  layer.capabilities.exportMap.supportsSublayerDefinitionExpression = true;
  map.add(layer);
});

function visListItemCreate(event){
  let item = event.item;
  const item_type = item.layer.type
  if (item_type === "tile"){
    const tileSublyrs = item.layer.allSublayers
    let sublyrObjects = []
    for(var i = 0; i&amp;lt;tileSublyrs.items.length; i++){
      sublyrObjects.push(tileSublyrs.items[i])
    }
  }
  else{
    item.hidden = true
  }
};
  
const layerList = new LayerList({
  view,
  selectionEnabled: true,
  listItemCreatedFunction: visListItemCreate,
  container: "layers-container"
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the properties that the cache is showing:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="moremeowbell_1-1679677915235.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66216iC35F960277E5B4C2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="moremeowbell_1-1679677915235.png" alt="moremeowbell_1-1679677915235.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas as to what is going on and how to fix it?&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 17:13:18 GMT</pubDate>
    <dc:creator>moremeowbell</dc:creator>
    <dc:date>2023-03-24T17:13:18Z</dc:date>
    <item>
      <title>ESRI JS 4.x TileLayer() Capabilities Property</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-4-x-tilelayer-capabilities-property/m-p/1271443#M80851</link>
      <description>&lt;P&gt;I have a cached map image service that I am calling in a JS web app (JS 4.x) using TileLayer(). The cached service has about 20 sublayers in it. My goal is to allow end-users to toggle each sublayer's visibility. According to documentation (&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html&lt;/A&gt;) you can access "&lt;SPAN&gt;supportsSublayerVisibility" via the Capabilities property. I have set that parameter to "true." When I try and toggle the visibility, the "eye" changes on click, but the data in the map is not affected (i.e. the visibility does not actually change).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here is an image of my LayerList()&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="moremeowbell_0-1679677565140.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66215i340770221D46EA05/image-size/medium?v=v2&amp;amp;px=400" role="button" title="moremeowbell_0-1679677565140.png" alt="moremeowbell_0-1679677565140.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the portion of my code that touches the dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let layer = new TileLayer({
  portalItem: {
    id: "PORTAL ID",
  }
});

layer.load()
.then(function(){
  layer.capabilities.exportMap.supportsSublayerVisibility = true;
  layer.capabilities.exportMap.supportsDynamicLayers = true;
  layer.capabilities.exportMap.supportsSublayersChanges = true;
  layer.capabilities.exportMap.supportsSublayerDefinitionExpression = true;
  map.add(layer);
});

function visListItemCreate(event){
  let item = event.item;
  const item_type = item.layer.type
  if (item_type === "tile"){
    const tileSublyrs = item.layer.allSublayers
    let sublyrObjects = []
    for(var i = 0; i&amp;lt;tileSublyrs.items.length; i++){
      sublyrObjects.push(tileSublyrs.items[i])
    }
  }
  else{
    item.hidden = true
  }
};
  
const layerList = new LayerList({
  view,
  selectionEnabled: true,
  listItemCreatedFunction: visListItemCreate,
  container: "layers-container"
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the properties that the cache is showing:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="moremeowbell_1-1679677915235.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66216iC35F960277E5B4C2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="moremeowbell_1-1679677915235.png" alt="moremeowbell_1-1679677915235.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas as to what is going on and how to fix it?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 17:13:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-4-x-tilelayer-capabilities-property/m-p/1271443#M80851</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2023-03-24T17:13:18Z</dc:date>
    </item>
  </channel>
</rss>

