<?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 JavaScript only shows map if the code is inside the head in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-only-shows-map-if-the-code-is-inside/m-p/1128857#M75690</link>
    <description>&lt;P&gt;I'm in a project that I will need to show a map of "arcgis", can not be the map of google Maps, on the site of "arcgis" there is an example to show the code with javascript, here's the link:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/display-a-map/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developers.arcgis.com/javascript/latest/display-a-map/&lt;/A&gt;, in the example the code is placed in the "head" of html, placing the head code as shown in the tutorial works, but in the project the "head" is in a template, and not on the page I want to show the map. The code of arcgis is as follows: .&lt;/P&gt;&lt;PRE&gt;&amp;lt; html&amp;gt;
  &amp;lt;head&amp;gt;
   &amp;lt;meta charset="utf-8" /&amp;gt;      
    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.22/esri/themes/light/main.css"&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.22/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require(["esri/config","esri/Map", "esri/views/MapView"], function (esriConfig,Map, MapView) {
        

       // Here will come the implementation of the map

     });
   &amp;lt;/script&amp;gt;

   &amp;lt; /head&amp;gt;
   &amp;lt; body&amp;gt;
  &amp;lt;div id="viewDiv"&amp;gt;The map will appear here&amp;lt;/div&amp;gt;
 &amp;lt; /body&amp;gt;
 &amp;lt; /html&amp;gt;&lt;/PRE&gt;&lt;P&gt;If I remove that part of the code that's in the head&lt;/P&gt;&lt;PRE&gt;&amp;lt;script&amp;gt;
  require(["esri/config","esri/Map", "esri/views/MapView"], function (esriConfig,Map, MapView) 
 {

   // Here will come the implementation of the map, where I will inform the coordinates

 });
&amp;lt;/script&amp;gt;
&amp;lt; div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;P&gt;And put on the page &lt;A href="https://www.unionwellrussia.com/" target="_self"&gt;I&lt;/A&gt; want to show the map does not load ... No error appears in the console, simply does not load, I put several "consoles.log(" to follow the processing and everything is ok, apparently it's all loaded&lt;/P&gt;&lt;P&gt;There is a project that uses this map, but the implementation was done in Angular, the code is as follows:&lt;/P&gt;&lt;PRE&gt;return loadModules([
        "esri/config",
        "esri/Map",
        "esri/views/MapView",
    ]).then(([esriConfig, Map, MapView]) =&amp;gt; {

        // Starts the map implementation by picking up the coordinates
        ...
        ...&lt;/PRE&gt;&lt;P&gt;Is there any way to implement in javaScript something similar to what was implemented in Angular?&lt;/P&gt;&lt;P&gt;I need to click a button and make that call to JavaScript&lt;/P&gt;&lt;P&gt;The project is Java 7 with PrimeFaces 3.5&lt;/P&gt;</description>
    <pubDate>Sun, 26 Dec 2021 08:50:01 GMT</pubDate>
    <dc:creator>Yasmndavidkh</dc:creator>
    <dc:date>2021-12-26T08:50:01Z</dc:date>
    <item>
      <title>JavaScript only shows map if the code is inside the head</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-only-shows-map-if-the-code-is-inside/m-p/1128857#M75690</link>
      <description>&lt;P&gt;I'm in a project that I will need to show a map of "arcgis", can not be the map of google Maps, on the site of "arcgis" there is an example to show the code with javascript, here's the link:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/display-a-map/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developers.arcgis.com/javascript/latest/display-a-map/&lt;/A&gt;, in the example the code is placed in the "head" of html, placing the head code as shown in the tutorial works, but in the project the "head" is in a template, and not on the page I want to show the map. The code of arcgis is as follows: .&lt;/P&gt;&lt;PRE&gt;&amp;lt; html&amp;gt;
  &amp;lt;head&amp;gt;
   &amp;lt;meta charset="utf-8" /&amp;gt;      
    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.22/esri/themes/light/main.css"&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.22/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require(["esri/config","esri/Map", "esri/views/MapView"], function (esriConfig,Map, MapView) {
        

       // Here will come the implementation of the map

     });
   &amp;lt;/script&amp;gt;

   &amp;lt; /head&amp;gt;
   &amp;lt; body&amp;gt;
  &amp;lt;div id="viewDiv"&amp;gt;The map will appear here&amp;lt;/div&amp;gt;
 &amp;lt; /body&amp;gt;
 &amp;lt; /html&amp;gt;&lt;/PRE&gt;&lt;P&gt;If I remove that part of the code that's in the head&lt;/P&gt;&lt;PRE&gt;&amp;lt;script&amp;gt;
  require(["esri/config","esri/Map", "esri/views/MapView"], function (esriConfig,Map, MapView) 
 {

   // Here will come the implementation of the map, where I will inform the coordinates

 });
&amp;lt;/script&amp;gt;
&amp;lt; div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;P&gt;And put on the page &lt;A href="https://www.unionwellrussia.com/" target="_self"&gt;I&lt;/A&gt; want to show the map does not load ... No error appears in the console, simply does not load, I put several "consoles.log(" to follow the processing and everything is ok, apparently it's all loaded&lt;/P&gt;&lt;P&gt;There is a project that uses this map, but the implementation was done in Angular, the code is as follows:&lt;/P&gt;&lt;PRE&gt;return loadModules([
        "esri/config",
        "esri/Map",
        "esri/views/MapView",
    ]).then(([esriConfig, Map, MapView]) =&amp;gt; {

        // Starts the map implementation by picking up the coordinates
        ...
        ...&lt;/PRE&gt;&lt;P&gt;Is there any way to implement in javaScript something similar to what was implemented in Angular?&lt;/P&gt;&lt;P&gt;I need to click a button and make that call to JavaScript&lt;/P&gt;&lt;P&gt;The project is Java 7 with PrimeFaces 3.5&lt;/P&gt;</description>
      <pubDate>Sun, 26 Dec 2021 08:50:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-only-shows-map-if-the-code-is-inside/m-p/1128857#M75690</guid>
      <dc:creator>Yasmndavidkh</dc:creator>
      <dc:date>2021-12-26T08:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript only shows map if the code is inside the head</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-only-shows-map-if-the-code-is-inside/m-p/1128872#M75691</link>
      <description>&lt;P&gt;Hello, the code below works for me. Substitute your API KEY appropriately.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&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;ArcGIS API for JavaScript Tutorials: Display a map&amp;lt;/title&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.22/esri/themes/light/main.css"
    /&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;This is an ArcGIS Map&amp;lt;/h1&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.22/"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script&amp;gt;
      require(["esri/config", "esri/Map", "esri/views/MapView"], function (
        esriConfig,
        Map,
        MapView
      ) {
        esriConfig.apiKey =
          "YOUR_API_KEY";
        const map = new Map({
          basemap: "arcgis-topographic", // Basemap layer service
        });

        const view = new MapView({
          map: map,
          center: [-118.805, 34.027], // Longitude, latitude
          zoom: 13, // Zoom level
          container: "viewDiv", // Div element
        });
      });
    &amp;lt;/script&amp;gt;
    &amp;lt;div style="height: 50%; width: 50%" id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Which should render like:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JordiMonkDeveloper_0-1640567452496.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/30359iD5980A4BF5E831E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JordiMonkDeveloper_0-1640567452496.png" alt="JordiMonkDeveloper_0-1640567452496.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that what you wanted?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 Dec 2021 01:10:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-only-shows-map-if-the-code-is-inside/m-p/1128872#M75691</guid>
      <dc:creator>Jordi-Monk-Developer</dc:creator>
      <dc:date>2021-12-27T01:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript only shows map if the code is inside the head</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-only-shows-map-if-the-code-is-inside/m-p/1130022#M75755</link>
      <description>&lt;P&gt;It looks like you might be missing the CSS for the viewDiv. Here's the snippet from the sample:&lt;/P&gt;&lt;PRE&gt;  &amp;lt;style&amp;gt;
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  &amp;lt;/style&amp;gt;&lt;/PRE&gt;&lt;P&gt;Or you can just add the needed sty&lt;A href="https://tinyurl.com/3xn3cauj/" target="_self"&gt;l&lt;/A&gt;e when creating the div:&lt;/P&gt;&lt;PRE&gt;&amp;lt;div id="viewDiv" style="height: 100%;width: 100%;"&amp;gt;&amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 10:10:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-only-shows-map-if-the-code-is-inside/m-p/1130022#M75755</guid>
      <dc:creator>WorldZone</dc:creator>
      <dc:date>2022-01-03T10:10:10Z</dc:date>
    </item>
  </channel>
</rss>

