<?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: Loading WebMap using Esri API for Javascript in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195609#M78050</link>
    <description>&lt;P&gt;Set the portalUrl of the esriConfig object you import, you're creating a new object and overwriting the default one.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;esriConfig.portalUrl = "https://myHostName.esri.com/arcgis"&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 25 Jul 2022 20:17:26 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2022-07-25T20:17:26Z</dc:date>
    <item>
      <title>Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195593#M78047</link>
      <description>&lt;P&gt;I am attempting a very basic script that loads a Portal WebMap using the Esri JS API. Here is the error message I am getting:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;EDIT: For some reason it seems to be directing towards &lt;A href="http://www.arcgis.com" target="_blank"&gt;www.arcgis.com&lt;/A&gt;&amp;nbsp;instead of my portal...&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE&gt;(index):&lt;SPAN class=""&gt;146&lt;/SPAN&gt; [esri.&lt;SPAN class=""&gt;WebMap&lt;/SPAN&gt;] #&lt;SPAN class=""&gt;load&lt;/SPAN&gt;() &lt;SPAN class=""&gt;Failed&lt;/SPAN&gt; to load web map 
l
&lt;SPAN class=""&gt;details&lt;/SPAN&gt;:
&lt;SPAN class=""&gt;error&lt;/SPAN&gt;: l
&lt;SPAN class=""&gt;details&lt;/SPAN&gt;:
&lt;SPAN class=""&gt;getHeader&lt;/SPAN&gt;: &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;V&lt;/SPAN&gt;=&amp;gt;&lt;/SPAN&gt;ya.&lt;SPAN class=""&gt;headers&lt;/SPAN&gt;.&lt;SPAN class=""&gt;get&lt;/SPAN&gt;(V)
&lt;SPAN class=""&gt;httpStatus&lt;/SPAN&gt;: &lt;SPAN class=""&gt;400&lt;/SPAN&gt;
&lt;SPAN class=""&gt;messageCode&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"CONT_0001"&lt;/SPAN&gt;
&lt;SPAN class=""&gt;messages&lt;/SPAN&gt;: []
&lt;SPAN class=""&gt;raw&lt;/SPAN&gt;: {&lt;SPAN class=""&gt;code&lt;/SPAN&gt;: &lt;SPAN class=""&gt;400&lt;/SPAN&gt;, &lt;SPAN class=""&gt;messageCode&lt;/SPAN&gt;: &lt;SPAN class=""&gt;'CONT_0001'&lt;/SPAN&gt;, &lt;SPAN class=""&gt;message&lt;/SPAN&gt;: &lt;SPAN class=""&gt;'Item does not exist or is inaccessible.'&lt;/SPAN&gt;, &lt;SPAN class=""&gt;details&lt;/SPAN&gt;: &lt;SPAN class=""&gt;Array&lt;/SPAN&gt;(&lt;SPAN class=""&gt;0&lt;/SPAN&gt;)}
&lt;SPAN class=""&gt;requestOptions&lt;/SPAN&gt;: {&lt;SPAN class=""&gt;authMode&lt;/SPAN&gt;: &lt;SPAN class=""&gt;'auto'&lt;/SPAN&gt;, &lt;SPAN class=""&gt;body&lt;/SPAN&gt;: &lt;SPAN class=""&gt;null&lt;/SPAN&gt;, &lt;SPAN class=""&gt;cacheBust&lt;/SPAN&gt;: &lt;SPAN class=""&gt;false&lt;/SPAN&gt;, &lt;SPAN class=""&gt;method&lt;/SPAN&gt;: &lt;SPAN class=""&gt;'auto'&lt;/SPAN&gt;, &lt;SPAN class=""&gt;query&lt;/SPAN&gt;: {…}, …}
&lt;SPAN class=""&gt;ssl&lt;/SPAN&gt;: &lt;SPAN class=""&gt;false&lt;/SPAN&gt;
&lt;SPAN class=""&gt;subCode&lt;/SPAN&gt;: &lt;SPAN class=""&gt;undefined&lt;/SPAN&gt;
&lt;SPAN class=""&gt;url&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"https://www.arcgis.com/sharing/rest/content/items/c1127b4c1e3e4ab9bd3005192f6e6731"&lt;/SPAN&gt;
[[&lt;SPAN class=""&gt;Prototype&lt;/SPAN&gt;]]: &lt;SPAN class=""&gt;Object&lt;/SPAN&gt;
&lt;SPAN class=""&gt;message&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"Item does not exist or is inaccessible."&lt;/SPAN&gt;
&lt;SPAN class=""&gt;name&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"request:server"&lt;/SPAN&gt;
[[&lt;SPAN class=""&gt;Prototype&lt;/SPAN&gt;]]: c
[[&lt;SPAN class=""&gt;Prototype&lt;/SPAN&gt;]]: &lt;SPAN class=""&gt;Object&lt;/SPAN&gt;
&lt;SPAN class=""&gt;message&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"Failed to load portal item"&lt;/SPAN&gt;
&lt;SPAN class=""&gt;name&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"webmap:load-portal-item"&lt;/SPAN&gt;
[[&lt;SPAN class=""&gt;Prototype&lt;/SPAN&gt;]]: c&lt;/PRE&gt;&lt;P&gt;Here is my JS script:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;require&lt;/SPAN&gt;([&lt;SPAN class=""&gt;"esri/config"&lt;/SPAN&gt;,&lt;SPAN class=""&gt;"esri/views/MapView"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"esri/WebMap"&lt;/SPAN&gt;], 
  &lt;SPAN class=""&gt;(&lt;SPAN class=""&gt;esriConfig, MapView, WebMap&lt;/SPAN&gt;) =&amp;gt;&lt;/SPAN&gt; {

  &lt;SPAN class=""&gt;var&lt;/SPAN&gt; esriConfig = {
    &lt;SPAN class=""&gt;portalUrl&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"https://domain/portal/home/"&lt;/SPAN&gt;,
  };

  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; webmap = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;WebMap&lt;/SPAN&gt;({
    &lt;SPAN class=""&gt;portalItem&lt;/SPAN&gt;: {
      &lt;SPAN class=""&gt;// autocasts as new PortalItem()&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;id&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"c1127b4c1e3e4ab9bd3005192f6e6731"&lt;/SPAN&gt;
    }
  });

  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; view = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;MapView&lt;/SPAN&gt;({
    &lt;SPAN class=""&gt;map&lt;/SPAN&gt;: webmap,
    &lt;SPAN class=""&gt;container&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"viewDiv"&lt;/SPAN&gt;
  });
});&lt;/PRE&gt;&lt;P&gt;Here is my HTML script:&lt;/P&gt;&lt;PRE&gt;&amp;lt;!&lt;SPAN class=""&gt;DOCTYPE&lt;/SPAN&gt; html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="utf-8"&amp;gt;
  &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"&amp;gt;
  &amp;lt;title&amp;gt;Testing&amp;lt;/title&amp;gt;
  &amp;lt;style&amp;gt;
      #viewDiv {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
  &amp;lt;/style&amp;gt;
  &amp;lt;link 
  rel="stylesheet"
  href="https://js.arcgis.com/4.24/esri/themes/dark/main.css"
  /&amp;gt;

&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;script src="https://js.arcgis.com/4.24/"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;script src="js/test_main.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 20:28:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195593#M78047</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2022-07-25T20:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195602#M78048</link>
      <description>&lt;P&gt;This may be an authentication problem since your web map is private. Take a look at this &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-videos/identitymanager-in-the-arcgis-api-for-javascript/m-p/1191710" target="_self"&gt;post&lt;/A&gt; by&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 20:06:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195602#M78048</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-07-25T20:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195605#M78049</link>
      <description>&lt;P&gt;It's public, so I don't think that's the issue:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="moremeowbell_0-1658779683161.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/46720i9C23F940025F0FF2/image-size/large?v=v2&amp;amp;px=999" role="button" title="moremeowbell_0-1658779683161.png" alt="moremeowbell_0-1658779683161.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 20:08:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195605#M78049</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2022-07-25T20:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195609#M78050</link>
      <description>&lt;P&gt;Set the portalUrl of the esriConfig object you import, you're creating a new object and overwriting the default one.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;esriConfig.portalUrl = "https://myHostName.esri.com/arcgis"&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 25 Jul 2022 20:17:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195609#M78050</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-07-25T20:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195612#M78051</link>
      <description>&lt;P&gt;I'm using Portal and not AGOL which is why it has Portal at the end of the URL instead of arcgis:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="moremeowbell_0-1658780486886.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/46723i81586F085BEF1D52/image-size/large?v=v2&amp;amp;px=999" role="button" title="moremeowbell_0-1658780486886.png" alt="moremeowbell_0-1658780486886.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 20:21:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195612#M78051</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2022-07-25T20:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195625#M78053</link>
      <description>&lt;P&gt;if you are going to use the esriConfig global object, you need to put it in a script tag above the one that imports the map modules.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Or&lt;/EM&gt; you can import the esriConfig like you did and set the portalUrl on it&lt;/P&gt;&lt;P&gt;You can't do both in the same script tag&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 20:44:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195625#M78053</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-07-25T20:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195628#M78054</link>
      <description>&lt;P&gt;Could you give me an example? I'm kind of lost.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 20:49:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195628#M78054</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2022-07-25T20:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195656#M78055</link>
      <description>&lt;LI-CODE lang="javascript"&gt;require(["esri/config","esri/views/MapView", "esri/WebMap"], 
  (esriConfig, MapView, WebMap) =&amp;gt; {

// you are overriding the esriConfig object you imported
//   var esriConfig = {
//     portalUrl: "https://domain/portal/home/",
//   };

  esriConfig.portalUrl = "https://domain/portal/home/";

  const webmap = new WebMap({
    portalItem: {
      // autocasts as new PortalItem()
      id: "c1127b4c1e3e4ab9bd3005192f6e6731"
    }
  });

  const view = new MapView({
    map: webmap,
    container: "viewDiv"
  });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or if you want to make the esriConfig global, you can do this. You don't need to import or reference it in your own JavaScript if you do this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"&amp;gt;
    &amp;lt;title&amp;gt;Testing&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        #viewDiv {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
        }
    &amp;lt;/style&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.24/esri/themes/dark/main.css" /&amp;gt;
    &amp;lt;script&amp;gt;
        // If ou define it globally here
        // the API will pick it up.
        // But should be in the head
        // so it is created before the API
        var esriConfig = {
            portalUrl: "https://domain/portal/home/",
        };
    &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.24/"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;!-- Do not add the esriConfig your JavaScript if you do this --&amp;gt;
    &amp;lt;script src="js/test_main.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 21:45:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195656#M78055</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-07-25T21:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195855#M78064</link>
      <description>&lt;P&gt;Thanks for sending over some script! I totally get what you're saying now. However, when I put it in the HTML head, I'm getting a CORS error. When I put it in the JS script, I'm getting a CORS error as well. The only way that I have been able to get around this is by setting the global variable in the JS script...&amp;nbsp; The part that doesn't make sense is that it's saying I'm trying to fetch the WebMap item from here rather than my Portal:&amp;nbsp;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN class=""&gt;url&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;'&lt;A href="https://www.arcgis.com/sharing/rest/content/items/" target="_blank" rel="noopener"&gt;https://www.arcgis.com/sharing/rest/content/items/&lt;/A&gt;....}&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 12:02:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1195855#M78064</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2022-07-26T12:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Loading WebMap using Esri API for Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1202452#M78274</link>
      <description>&lt;P&gt;Looks like the /home at the end of the url was messing things up! Got it resolved.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 16:18:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/loading-webmap-using-esri-api-for-javascript/m-p/1202452#M78274</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2022-08-12T16:18:39Z</dc:date>
    </item>
  </channel>
</rss>

