<?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: Online layer from enterprise is not working in Swift Maps SDK Questions</title>
    <link>https://community.esri.com/t5/swift-maps-sdk-questions/online-layer-from-enterprise-is-not-working/m-p/1558968#M458</link>
    <description>&lt;P&gt;Hi Maria, thanks for asking. This behavior is expected.&lt;/P&gt;
&lt;P&gt;When you create a feature layer like the code shown above&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="swift"&gt;let featureLayer = FeatureLayer(featureTable: ServiceFeatureTable(item: portalItem))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is using the initializer of&amp;nbsp;&lt;EM&gt;ServiceFeatureTable&lt;/EM&gt;,&amp;nbsp;&lt;A href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/servicefeaturetable/init(item:)" target="_self"&gt;ServiceFeatureTable/init(item:)&lt;/A&gt;&amp;nbsp;here. It is a "shorthand" initializer that would attempt creating the table from the first layer on the service, with has layerID = 0.&lt;/P&gt;
&lt;P&gt;This initializer is there to meet a popular demand which a hosted feature service only has 1 feature layer (layerID = 0) that is being used in a map.&lt;/P&gt;
&lt;P&gt;To create a feature layer other than layerID = 0, consider either of these 2 initializers&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/featurelayer/init(featureserviceitem:layerid:)" target="_self"&gt;FeatureLayer/init(featureServiceItem:layerID:)&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/servicefeaturetable/init(item:layerid:)" target="_self"&gt;ServiceFeatureTable/init(item:layerID:)&lt;/A&gt;
&lt;UL&gt;
&lt;LI&gt;*(or you can construct the raw URL with different layerID and use&amp;nbsp;&lt;A href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/servicefeaturetable/init(url:)" target="_self"&gt;ServiceFeatureTable/init(url:)&lt;/A&gt;&amp;nbsp;to create the different tables for each layer, if that is what you like)&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Both allow you to specify the layerID of a layer on the feature service.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;p.s., there should be a load error if the &lt;EM&gt;try await featureLayer.load()&lt;/EM&gt; is called.&lt;/P&gt;
&lt;P&gt;Let me know if you have further questions. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2024 22:25:43 GMT</pubDate>
    <dc:creator>Ting</dc:creator>
    <dc:date>2024-11-14T22:25:43Z</dc:date>
    <item>
      <title>Online layer from enterprise is not working</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/online-layer-from-enterprise-is-not-working/m-p/1558953#M457</link>
      <description>&lt;P&gt;When the user logs in to the enterprise portal and selects the layer he wants to see, that layer is not displaying.&lt;/P&gt;&lt;P&gt;This is happening with all the layers that have an ID different from 0.&lt;/P&gt;&lt;P&gt;for example in this case the ID layer is 2:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-11-14 at 4.27.18 PM.png" style="width: 322px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119592i1B52DE65AFD97E71/image-dimensions/322x256?v=v2" width="322" height="256" role="button" title="Screenshot 2024-11-14 at 4.27.18 PM.png" alt="Screenshot 2024-11-14 at 4.27.18 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;With any layer with an ID equal to 0, it works very well.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-11-14 at 4.46.35 PM.png" style="width: 261px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119597i2201A04CCB4F258F/image-dimensions/261x212?v=v2" width="261" height="212" role="button" title="Screenshot 2024-11-14 at 4.46.35 PM.png" alt="Screenshot 2024-11-14 at 4.46.35 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;The URL is&amp;nbsp;&lt;A href="https://server.xyzxyzxyzxyzxy" target="_blank" rel="noopener"&gt;https://server.xyzxyzxyzxyzxy&lt;/A&gt;&lt;EM&gt;&lt;STRONG&gt;/FeatureServer,&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;but we could see in the logs this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-11-14 at 9.42.13 AM.png" style="width: 522px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119595i6A8599CEA1F76203/image-dimensions/522x150?v=v2" width="522" height="150" role="button" title="Screenshot 2024-11-14 at 9.42.13 AM.png" alt="Screenshot 2024-11-14 at 9.42.13 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, it is like the "/0" was added, that's why the layer is not displaying, because the URL should be: &lt;A href="https://server.xyzxyzxyzxyzxy" target="_blank" rel="noopener"&gt;https://server.xyzxyzxyzxyzxy&lt;/A&gt;&lt;EM&gt;&lt;STRONG&gt;/FeatureServer/2&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;As it is a private layer, the app is using the &lt;EM&gt;&lt;STRONG&gt;portal item ID &lt;/STRONG&gt;&lt;/EM&gt;instead of the&lt;EM&gt;&lt;STRONG&gt; URL&lt;/STRONG&gt;&lt;/EM&gt; to get the layer: &lt;EM&gt;&lt;STRONG&gt;ServiceFeatureTable(item: portalItem),&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;but the layer is not displaying in the map, and the app doesn't have any error from the library.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;var featureLayer: (PortalProtocol, String) -&amp;gt; LayerProtocol? =  { portal, portalItemID in
        guard let itemID = ArcGIS.Item.ID(portalItemID), let portal = portal as? Portal else { return nil }
        let portalItem = PortalItem(portal: portal, id: itemID)
        return FeatureLayer(featureTable: ServiceFeatureTable(item: portalItem))
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 21:55:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/online-layer-from-enterprise-is-not-working/m-p/1558953#M457</guid>
      <dc:creator>MariaPaulaGomezP</dc:creator>
      <dc:date>2024-11-14T21:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Online layer from enterprise is not working</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/online-layer-from-enterprise-is-not-working/m-p/1558968#M458</link>
      <description>&lt;P&gt;Hi Maria, thanks for asking. This behavior is expected.&lt;/P&gt;
&lt;P&gt;When you create a feature layer like the code shown above&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="swift"&gt;let featureLayer = FeatureLayer(featureTable: ServiceFeatureTable(item: portalItem))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is using the initializer of&amp;nbsp;&lt;EM&gt;ServiceFeatureTable&lt;/EM&gt;,&amp;nbsp;&lt;A href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/servicefeaturetable/init(item:)" target="_self"&gt;ServiceFeatureTable/init(item:)&lt;/A&gt;&amp;nbsp;here. It is a "shorthand" initializer that would attempt creating the table from the first layer on the service, with has layerID = 0.&lt;/P&gt;
&lt;P&gt;This initializer is there to meet a popular demand which a hosted feature service only has 1 feature layer (layerID = 0) that is being used in a map.&lt;/P&gt;
&lt;P&gt;To create a feature layer other than layerID = 0, consider either of these 2 initializers&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/featurelayer/init(featureserviceitem:layerid:)" target="_self"&gt;FeatureLayer/init(featureServiceItem:layerID:)&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/servicefeaturetable/init(item:layerid:)" target="_self"&gt;ServiceFeatureTable/init(item:layerID:)&lt;/A&gt;
&lt;UL&gt;
&lt;LI&gt;*(or you can construct the raw URL with different layerID and use&amp;nbsp;&lt;A href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/servicefeaturetable/init(url:)" target="_self"&gt;ServiceFeatureTable/init(url:)&lt;/A&gt;&amp;nbsp;to create the different tables for each layer, if that is what you like)&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Both allow you to specify the layerID of a layer on the feature service.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;p.s., there should be a load error if the &lt;EM&gt;try await featureLayer.load()&lt;/EM&gt; is called.&lt;/P&gt;
&lt;P&gt;Let me know if you have further questions. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 22:25:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/online-layer-from-enterprise-is-not-working/m-p/1558968#M458</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2024-11-14T22:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Online layer from enterprise is not working</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/online-layer-from-enterprise-is-not-working/m-p/1559012#M459</link>
      <description>&lt;P&gt;To add to the answer above, if you are trying to create a "layer browser" type of experience, another way is to create a&amp;nbsp;&lt;A class="router-link-exact-active router-link-active inline-link" href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/servicegeodatabase" aria-current="page" target="_blank"&gt;&lt;CODE data-v-05f4a5b7=""&gt;Service&lt;WBR data-v-05f4a5b7="" /&gt;Geodatabase&lt;/CODE&gt;&lt;/A&gt;&amp;nbsp;from the portal item, then uses its&amp;nbsp;&lt;A class="link has-adjacent-elements" href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/servicegeodatabase/connectedtables" data-v-63be6b46="" target="_blank"&gt;&lt;CODE class="decorated-title" data-v-06ec7395="" data-v-63be6b46=""&gt;&lt;SPAN class="identifier" data-v-06ec7395=""&gt;connected&lt;WBR data-v-06ec7395="" /&gt;Tables&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/A&gt;&amp;nbsp;property to access each table of a feature service. You can also use the&amp;nbsp;&lt;A class="link has-adjacent-elements" href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/servicegeodatabase/serviceinfo" data-v-63be6b46="" target="_blank"&gt;&lt;CODE class="decorated-title" data-v-06ec7395="" data-v-63be6b46=""&gt;&lt;SPAN class="identifier" data-v-06ec7395=""&gt;service&lt;WBR data-v-06ec7395="" /&gt;Info&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/A&gt;&amp;nbsp;property to get additional information about he layers and layerIDs in the feature service.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 01:06:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/online-layer-from-enterprise-is-not-working/m-p/1559012#M459</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2024-11-15T01:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Online layer from enterprise is not working</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/online-layer-from-enterprise-is-not-working/m-p/1559337#M461</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/440371"&gt;@Ting&lt;/a&gt;, that helped me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 18:57:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/online-layer-from-enterprise-is-not-working/m-p/1559337#M461</guid>
      <dc:creator>MariaPaulaGomezP</dc:creator>
      <dc:date>2024-11-15T18:57:54Z</dc:date>
    </item>
  </channel>
</rss>

