<?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: Add sublayers from a Hosted Feature Layer View in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-sublayers-from-a-hosted-feature-layer-view/m-p/1495668#M84908</link>
    <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt; , got it working!&lt;/P&gt;&lt;P&gt;Took a bit of finagling in TypeScript...&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const pItem = new PortalItem({
  id: '4601abb43d564387a785aeaaba8d7486'
})

Layer.fromPortalItem({
  portalItem: pItem
}).then(async (layer) =&amp;gt; {
  await layer.load()
  const groupLayer = layer as GroupLayer
  this.map.add(groupLayer.layers.at(0))
})&lt;/LI-CODE&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Curiously, sublayer 1 came through as item 0. Easy enough to sort out though.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jun 2024 21:09:14 GMT</pubDate>
    <dc:creator>Jeff-Reinhart</dc:creator>
    <dc:date>2024-06-20T21:09:14Z</dc:date>
    <item>
      <title>Add sublayers from a Hosted Feature Layer View</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-sublayers-from-a-hosted-feature-layer-view/m-p/1495366#M84905</link>
      <description>&lt;P&gt;Is it possible to add individual sublayers from a Hosted Feature Layer View? Please see &lt;A href="https://arcgis.dnr.state.mn.us/portal/home/item.html?id=4601abb43d564387a785aeaaba8d7486" target="_self"&gt;this portal item&lt;/A&gt; for example. When I declare this as&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;const pItem = new PortalItem({&lt;BR /&gt;&amp;nbsp; &amp;nbsp; id: '4601abb43d564387a785aeaaba8d7486'&lt;BR /&gt;})&lt;/P&gt;&lt;P&gt;const ftLayer = new FeatureLayer({&lt;BR /&gt;&amp;nbsp; &amp;nbsp; portalItem: pItem&lt;BR /&gt;})&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;All I get is sublayer 0. I have looked through properties on the PortalItem and am not seeing a way to reference individual sublayers. The sublayers on the view do not have an ID to reference. I have tried adding&amp;nbsp;&amp;amp;sublayer=1 to the PortalItem.id. Is there some other class I should be using between the FeatureLayer and the PortalItem? I looked at GroupLayer for that, but that seems to be built on the client side rather than unpacking something from the server.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 14:01:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-sublayers-from-a-hosted-feature-layer-view/m-p/1495366#M84905</guid>
      <dc:creator>Jeff-Reinhart</dc:creator>
      <dc:date>2024-06-20T14:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Add sublayers from a Hosted Feature Layer View</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-sublayers-from-a-hosted-feature-layer-view/m-p/1495482#M84906</link>
      <description>&lt;P&gt;Ah. For stuff like this, you can use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#fromPortalItem" target="_blank" rel="noopener"&gt;Layer.fromPortalItem&lt;/A&gt;. It's useful to load an entire FeatureService or any layer where you have the item, but don't know the layer type.&lt;/P&gt;&lt;P&gt;You can do something like this.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Layer.fromPortalItem({
	portalItem: {
		id: "4601abb43d564387a785aeaaba8d7486",
	}
}).then(async (layer) =&amp;gt; {
	// Will be a GroupLayer
	// await layer.load();
	// layer.layers -&amp;gt; [a, b] has two layers in the group
	// pull out layer you are interested in
	// and add only that layer.
	// map.add(layer.layers.at(1));
	
	// add the whole GroupLayer
	map.add(layer);
});&lt;/LI-CODE&gt;&lt;P&gt;Here is a &lt;A href="https://codepen.io/odoe/pen/VwOXjOK?editors=0010" target="_blank" rel="noopener"&gt;codepen&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 16:25:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-sublayers-from-a-hosted-feature-layer-view/m-p/1495482#M84906</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2024-06-20T16:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Add sublayers from a Hosted Feature Layer View</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-sublayers-from-a-hosted-feature-layer-view/m-p/1495668#M84908</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt; , got it working!&lt;/P&gt;&lt;P&gt;Took a bit of finagling in TypeScript...&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const pItem = new PortalItem({
  id: '4601abb43d564387a785aeaaba8d7486'
})

Layer.fromPortalItem({
  portalItem: pItem
}).then(async (layer) =&amp;gt; {
  await layer.load()
  const groupLayer = layer as GroupLayer
  this.map.add(groupLayer.layers.at(0))
})&lt;/LI-CODE&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Curiously, sublayer 1 came through as item 0. Easy enough to sort out though.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 21:09:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-sublayers-from-a-hosted-feature-layer-view/m-p/1495668#M84908</guid>
      <dc:creator>Jeff-Reinhart</dc:creator>
      <dc:date>2024-06-20T21:09:14Z</dc:date>
    </item>
  </channel>
</rss>

