<?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 Use tabs to switch between web map and dashboard in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-tabs-to-switch-between-web-map-and-dashboard/m-p/1182811#M77672</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I'm trying to create a tabbed map view as is seen&amp;nbsp;&lt;A href="https://utahfireinfo.gov/fire-restrictions/" target="_self"&gt;on this website (that I manage).&lt;/A&gt;&amp;nbsp;However, I would like one of the tabs to be a map, and the other to be a dashboard. Is this possible? Code for that map is below. Maybe this isn't the right template to use? Any advice would be appreciated. Thanks!&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;Utah Fire Restrictions - Swap Maps&amp;lt;/title&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
        overflow: hidden;
      }

      #viewDiv {
        position: absolute;
        right: 0;
        left: 0;
        top: 60px;
        bottom: 0;
      }

      .header {
        position: absolute;
        top: 0;
        width: 100%;
        height: 10%;
      }

      .btns {
        margin: 0 auto;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        overflow: auto;
      }

      .btn-switch {
        flex-grow: 4;
        background-color: #ffa87d;
        color: #fff;
        font-size: 1.2em;
        font-weight: bold;
        margin: 1px;
        width: 50%;
        padding: 20px;
        overflow: auto;
        text-align: center;
        cursor: pointer;
      }

      .active-map {
        color: #fff;
        background-color: #ea763c;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.19/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require(["esri/views/MapView", "esri/WebMap", "esri/widgets/Search", "esri/widgets/BasemapToggle"], function(MapView, WebMap, Search, BasemapToggle) {
        var webmapids = [
          "dc1ab69b0d48495d8da6534604d030d3",
          "658cbebc11334e72ba7b29d72cd9d8bd"
        ];

        /************************************************************
         * Create multiple WebMap instances
         ************************************************************/
        var webmaps = webmapids.map(function(webmapid) {
          return new WebMap({
            portalItem: {
              // autocasts as new PortalItem()
              id: webmapid
            }
          });
        });
		

        /************************************************************
         * Initialize the View with the first WebMap
         ************************************************************/
        var view = new MapView({
          map: webmaps[0],
          container: "viewDiv"
        });
		
		const searchWidget = new Search({
			view: view });
			// Adds the search widget below other elements in
			// the top left corner of the view
			view.ui.add(searchWidget, { position: "top-left",  index: 2
		});
		
		let basemapToggle = new BasemapToggle({
			view: view,  // The view that provides access to the map's "streets-vector" basemap
			nextBasemap: "streets-vector"  // Allows for toggling to the "hybrid" basemap
		});

        document.querySelector(".btns").addEventListener("click", function(event) {
          /************************************************************
           * On a button click, change the map of the View
           ************************************************************/
          var id = event.target.getAttribute("data-id");
          if (id) {
            var webmap = webmaps[id];
            view.map = webmap;
            var nodes = document.querySelectorAll(".btn-switch");
            for (var idx = 0; idx &amp;lt; nodes.length; idx++) {
              var node = nodes[idx];
              var mapIndex = node.getAttribute("data-id");
              if (mapIndex === id) {
                node.classList.add("active-map");
              } else {
                node.classList.remove("active-map");
              }
            }
          }
        });
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;section class="header esri-widget"&amp;gt;
      &amp;lt;div class="btns"&amp;gt;
        &amp;lt;div class="btn-switch active-map" data-id="0"&amp;gt;Campfire and Other Restrictions&amp;lt;/div&amp;gt;
        &amp;lt;div class="btn-switch" data-id="1"&amp;gt;Fireworks Restrictions&amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/section&amp;gt;
    &amp;lt;div id="viewDiv" class="esri-widget"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 14 Jun 2022 17:29:57 GMT</pubDate>
    <dc:creator>Michelle_Baragona</dc:creator>
    <dc:date>2022-06-14T17:29:57Z</dc:date>
    <item>
      <title>Use tabs to switch between web map and dashboard</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-tabs-to-switch-between-web-map-and-dashboard/m-p/1182811#M77672</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I'm trying to create a tabbed map view as is seen&amp;nbsp;&lt;A href="https://utahfireinfo.gov/fire-restrictions/" target="_self"&gt;on this website (that I manage).&lt;/A&gt;&amp;nbsp;However, I would like one of the tabs to be a map, and the other to be a dashboard. Is this possible? Code for that map is below. Maybe this isn't the right template to use? Any advice would be appreciated. Thanks!&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;Utah Fire Restrictions - Swap Maps&amp;lt;/title&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
        overflow: hidden;
      }

      #viewDiv {
        position: absolute;
        right: 0;
        left: 0;
        top: 60px;
        bottom: 0;
      }

      .header {
        position: absolute;
        top: 0;
        width: 100%;
        height: 10%;
      }

      .btns {
        margin: 0 auto;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        overflow: auto;
      }

      .btn-switch {
        flex-grow: 4;
        background-color: #ffa87d;
        color: #fff;
        font-size: 1.2em;
        font-weight: bold;
        margin: 1px;
        width: 50%;
        padding: 20px;
        overflow: auto;
        text-align: center;
        cursor: pointer;
      }

      .active-map {
        color: #fff;
        background-color: #ea763c;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.19/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require(["esri/views/MapView", "esri/WebMap", "esri/widgets/Search", "esri/widgets/BasemapToggle"], function(MapView, WebMap, Search, BasemapToggle) {
        var webmapids = [
          "dc1ab69b0d48495d8da6534604d030d3",
          "658cbebc11334e72ba7b29d72cd9d8bd"
        ];

        /************************************************************
         * Create multiple WebMap instances
         ************************************************************/
        var webmaps = webmapids.map(function(webmapid) {
          return new WebMap({
            portalItem: {
              // autocasts as new PortalItem()
              id: webmapid
            }
          });
        });
		

        /************************************************************
         * Initialize the View with the first WebMap
         ************************************************************/
        var view = new MapView({
          map: webmaps[0],
          container: "viewDiv"
        });
		
		const searchWidget = new Search({
			view: view });
			// Adds the search widget below other elements in
			// the top left corner of the view
			view.ui.add(searchWidget, { position: "top-left",  index: 2
		});
		
		let basemapToggle = new BasemapToggle({
			view: view,  // The view that provides access to the map's "streets-vector" basemap
			nextBasemap: "streets-vector"  // Allows for toggling to the "hybrid" basemap
		});

        document.querySelector(".btns").addEventListener("click", function(event) {
          /************************************************************
           * On a button click, change the map of the View
           ************************************************************/
          var id = event.target.getAttribute("data-id");
          if (id) {
            var webmap = webmaps[id];
            view.map = webmap;
            var nodes = document.querySelectorAll(".btn-switch");
            for (var idx = 0; idx &amp;lt; nodes.length; idx++) {
              var node = nodes[idx];
              var mapIndex = node.getAttribute("data-id");
              if (mapIndex === id) {
                node.classList.add("active-map");
              } else {
                node.classList.remove("active-map");
              }
            }
          }
        });
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;section class="header esri-widget"&amp;gt;
      &amp;lt;div class="btns"&amp;gt;
        &amp;lt;div class="btn-switch active-map" data-id="0"&amp;gt;Campfire and Other Restrictions&amp;lt;/div&amp;gt;
        &amp;lt;div class="btn-switch" data-id="1"&amp;gt;Fireworks Restrictions&amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/section&amp;gt;
    &amp;lt;div id="viewDiv" class="esri-widget"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Jun 2022 17:29:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-tabs-to-switch-between-web-map-and-dashboard/m-p/1182811#M77672</guid>
      <dc:creator>Michelle_Baragona</dc:creator>
      <dc:date>2022-06-14T17:29:57Z</dc:date>
    </item>
  </channel>
</rss>

