<?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: How do I change the basemap programmatically? in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792805#M4312</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jose,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; You can use &lt;A class="link-bare" href="https://developers.arcgis.com/javascript/3/jsapi/basemapgallery-amd.html#event-selection-change" title="https://developers.arcgis.com/javascript/3/jsapi/basemapgallery-amd.html#event-selection-change"&gt;https://developers.arcgis.com/javascript/3/jsapi/basemapgallery-amd.html#event-selection-change&lt;/A&gt;&amp;nbsp;before you destroy the _basemapGallery.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jan 2020 15:12:07 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2020-01-13T15:12:07Z</dc:date>
    <item>
      <title>How do I change the basemap programmatically?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792800#M4307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am building a custom widget for WAB. To start with, I just want to build a button that switches between the 'streets' and the 'topo' basemap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created a working widget and in it I have this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;let &lt;/SPAN&gt;newMap = &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;Map(&lt;SPAN style="color: #6a8759;"&gt;"map"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;{
  &lt;SPAN style="color: #9876aa;"&gt;basemap&lt;/SPAN&gt;: &lt;SPAN style="color: #6a8759;"&gt;"streets"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;center&lt;/SPAN&gt;: [-&lt;SPAN style="color: #6897bb;"&gt;105.255&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;40.022&lt;/SPAN&gt;]&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;zoom&lt;/SPAN&gt;: &lt;SPAN style="color: #6897bb;"&gt;13
&lt;/SPAN&gt;})&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #9876aa; font-weight: bold;"&gt;console&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;log&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;"newMap"&lt;/SPAN&gt;)
&lt;SPAN style="color: #9876aa; font-weight: bold;"&gt;console&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;log&lt;/SPAN&gt;(newMap)
&lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;map &lt;/SPAN&gt;= newMap&lt;/PRE&gt;&lt;P&gt;Which creates a new Map, and does not generate any errors, but also does not change the map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am guessing I need to do more than just `this.map = newMap`. But, what?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is no documentation on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:06:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792800#M4307</guid>
      <dc:creator>JoseVidal</dc:creator>
      <dc:date>2021-12-12T09:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the basemap programmatically?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792801#M4308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jose,&lt;/P&gt;&lt;P&gt;You should not recreate the map object unless you plan to display multiple map views.&lt;/P&gt;&lt;P&gt;To change a basemap you use the existing map object and use the function setBasemap&lt;/P&gt;&lt;P&gt;map.setBasemap("name_of_the_basemap");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;alternatively, you can use the toggle widget that has this functionality built-in -&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/jssamples/widget_toggle.html" title="https://developers.arcgis.com/javascript/3/jssamples/widget_toggle.html"&gt;Basemap Toggle | ArcGIS API for JavaScript 3.31&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or the basemap gallery widget, which is similar -&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/jssamples/widget_basemap.html" title="https://developers.arcgis.com/javascript/3/jssamples/widget_basemap.html"&gt;Basemap gallery | ArcGIS API for JavaScript 3.31&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2019 05:08:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792801#M4308</guid>
      <dc:creator>shaylavi</dc:creator>
      <dc:date>2019-12-23T05:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the basemap programmatically?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792802#M4309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a link to a thread about issues trying to use the JS API basemap toggle widget in WAB.&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="link-titled" href="https://community.esri.com/thread/161760#comment" title="https://community.esri.com/thread/161760#comment-534257" target="_blank"&gt;https://community.esri.com/thread/161760#comment-534257&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is how we switch a basemap in the custom Local Layer widget.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; bmLayerObj &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  url&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; url&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
  isReference&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;false&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; _newBasemap &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;Basemap&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  id&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'defaultBasemap'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
  title&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"blah blah"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
  layers&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;BasemapLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;bmLayerObj&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; _basemapGallery &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;BasemapGallery&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  showArcGISBasemaps&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;false&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
  map&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Map
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
_basemapGallery&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;add&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;_newBasemap&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
_basemapGallery&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;select&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'defaultBasemap'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
_basemapGallery&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;destroy&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:06:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792802#M4309</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T09:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the basemap programmatically?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792803#M4310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used the line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;map&lt;/SPAN&gt;.setBasemap(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"topo"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but, it does not do anything. The map remains the same. It does not produce an error either.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try Scheitlin's solution next.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jan 2020 20:17:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792803#M4310</guid>
      <dc:creator>JoseVidal</dc:creator>
      <dc:date>2020-01-11T20:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the basemap programmatically?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792804#M4311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked! Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I only had to change line 12 to: map: this.map. Uppercase this.Map does not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, I am executing a printtask right after changing the basemap and the print uses the old map. I am guessing it is because I have to wait until the basemap has changed before a call the printtask.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to get a callback (setup a .then()) for after the basemap changes?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jan 2020 20:48:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792804#M4311</guid>
      <dc:creator>JoseVidal</dc:creator>
      <dc:date>2020-01-11T20:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the basemap programmatically?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792805#M4312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jose,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; You can use &lt;A class="link-bare" href="https://developers.arcgis.com/javascript/3/jsapi/basemapgallery-amd.html#event-selection-change" title="https://developers.arcgis.com/javascript/3/jsapi/basemapgallery-amd.html#event-selection-change"&gt;https://developers.arcgis.com/javascript/3/jsapi/basemapgallery-amd.html#event-selection-change&lt;/A&gt;&amp;nbsp;before you destroy the _basemapGallery.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jan 2020 15:12:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792805#M4312</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2020-01-13T15:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the basemap programmatically?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792806#M4313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! That worked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2020 00:10:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/792806#M4313</guid>
      <dc:creator>JoseVidal</dc:creator>
      <dc:date>2020-01-14T00:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the basemap programmatically?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/1058483#M14500</link>
      <description>&lt;P&gt;Jose,&lt;/P&gt;&lt;P&gt;it sets the base map at a particular zoom level, but again it vanishes after we change the zoom level&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 13:30:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-do-i-change-the-basemap-programmatically/m-p/1058483#M14500</guid>
      <dc:creator>Adarshvarma</dc:creator>
      <dc:date>2021-05-17T13:30:28Z</dc:date>
    </item>
  </channel>
</rss>

