<?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: [4.10] Swapping web maps with different Portal URLs in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-10-swapping-web-maps-with-different-portal-urls/m-p/613371#M57389</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've found a workaround that allows me to swap web maps from different portals. Rather than setting the&amp;nbsp;esriConfig.portalUrl, it works when the Portal property of the web map's Portal Item is defined with the portal URL when creating the web map. Otherwise the Portal Item gets created with the wrong URLs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Updated workaround steps...&lt;/P&gt;&lt;UL style="background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;&lt;SPAN style="text-decoration: line-through; color: #ff0000;"&gt;esriConfig.portalUrl = portalUrl;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;identityManager.registerToken(token);&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;const webmap = new WebMap({&lt;BR /&gt;&amp;nbsp; &amp;nbsp; portalItem: { &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id: webMapId,&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;portal: {&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url: portalUrl&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; } &lt;BR /&gt;});&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;mapView.map = webmap;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This appears to be a bug, as the&amp;nbsp;portal property of PortalItem should default to the value set in config.portalUrl, &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#portal"&gt;as per the docs&lt;/A&gt;;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;The portal that contains the item. Defaults to the value in config.portalUrl (e.g. https://www.arcgis.com). Suggested to use config.portalUrl instead of this property.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Jan 2019 11:31:35 GMT</pubDate>
    <dc:creator>JosephHyland</dc:creator>
    <dc:date>2019-01-24T11:31:35Z</dc:date>
    <item>
      <title>[4.10] Swapping web maps with different Portal URLs</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-10-swapping-web-maps-with-different-portal-urls/m-p/613370#M57388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on an application that can store multiple web map configurations and load them up in the map view. Web maps can be from ArcGIS Online or different instances of Portal for ArcGIS. These are secured and I am generating a token to access them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When loading up each web map, I am doing the following...&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;esriConfig.portalUrl = portalUrl;&lt;/LI&gt;&lt;LI&gt;identityManager.registerToken(token);&lt;/LI&gt;&lt;LI&gt;const webmap = new WebMap({ portalItem: { id: webMapId } });&lt;/LI&gt;&lt;LI&gt;mapView.map = webmap;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This works&lt;/STRONG&gt; on the &lt;EM&gt;&lt;STRONG&gt;first&lt;/STRONG&gt; &lt;/EM&gt;web map to be loaded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I swap to another web map configuration and follow the same steps, the map doesn't load and I get the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;dojo.js:310 [esri.WebMap] #load() Failed to load web map&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;message: "Failed to load portal item"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I drill into the message details I see &lt;SPAN style="color: #ff0000;"&gt;"Item does not exist or is inaccessible"&lt;/SPAN&gt;. I see the URL for the item is appending the new web map ID to the items API endpoint URL of the &lt;STRONG&gt;first&lt;/STRONG&gt; web map that was loaded. If I try to load additional web maps they all fail, unless they have the same portal URL as the first web map loaded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I refresh and load a failed web map first, it loads fine and the other maps fail... so it's not an access/token issue for a specific web map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I debug, I can see IdentityManager has a "_portals" collection of URLs which&amp;nbsp;builds up with each new portal I attempt to access. It looks like the first _portals URL (&lt;SPAN&gt;_portals&lt;/SPAN&gt;[0]) may be getting used each time even though the portal URL is getting updated on the esriConfig.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(Edit: I've tried clearing out the _portals and serverInfos collections in IdentityManager but the old URL is still being used to form the items endpoint... can't see where this is being persisted)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Is this a bug?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Any suggestions?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to reset the Identity Manager? It's different to the other modules as "instead of returning a class constructor, it returns a singleton instance that has already been created by this module".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2019 15:57:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-10-swapping-web-maps-with-different-portal-urls/m-p/613370#M57388</guid>
      <dc:creator>JosephHyland</dc:creator>
      <dc:date>2019-01-23T15:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: [4.10] Swapping web maps with different Portal URLs</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-10-swapping-web-maps-with-different-portal-urls/m-p/613371#M57389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've found a workaround that allows me to swap web maps from different portals. Rather than setting the&amp;nbsp;esriConfig.portalUrl, it works when the Portal property of the web map's Portal Item is defined with the portal URL when creating the web map. Otherwise the Portal Item gets created with the wrong URLs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Updated workaround steps...&lt;/P&gt;&lt;UL style="background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;&lt;SPAN style="text-decoration: line-through; color: #ff0000;"&gt;esriConfig.portalUrl = portalUrl;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;identityManager.registerToken(token);&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;const webmap = new WebMap({&lt;BR /&gt;&amp;nbsp; &amp;nbsp; portalItem: { &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id: webMapId,&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;portal: {&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url: portalUrl&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; } &lt;BR /&gt;});&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;mapView.map = webmap;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This appears to be a bug, as the&amp;nbsp;portal property of PortalItem should default to the value set in config.portalUrl, &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#portal"&gt;as per the docs&lt;/A&gt;;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;The portal that contains the item. Defaults to the value in config.portalUrl (e.g. https://www.arcgis.com). Suggested to use config.portalUrl instead of this property.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2019 11:31:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-10-swapping-web-maps-with-different-portal-urls/m-p/613371#M57389</guid>
      <dc:creator>JosephHyland</dc:creator>
      <dc:date>2019-01-24T11:31:35Z</dc:date>
    </item>
  </channel>
</rss>

