<?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 Changing BaseMap from code in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/changing-basemap-from-code/m-p/1509763#M13872</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm currently working on a dark mode feature in ArcGIS Experience Builder (ExB) Developer that automatically changes the basemap. I've also integrated a basemap gallery widget within the map widget to provide more basemap options. Selecting a basemap from the gallery and toggling between dark modes works fine, however, there's an issue when toggling dark mode directly: the basemap gallery widget shows no basemap as selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case 1:&lt;/P&gt;&lt;P&gt;Select a light mode basemap &lt;SPAN&gt;from the basemap gallery&lt;/SPAN&gt;.&lt;BR /&gt;Select a dark mode basemap from the basemap gallery aswell.&lt;BR /&gt;Toggle dark mode.&lt;/P&gt;&lt;P&gt;In this case, everything works well and the correct basemap is shown in the gallery.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case 2:&lt;/P&gt;&lt;P&gt;Directly toggle dark mode.&lt;/P&gt;&lt;P&gt;In this scenario, no basemap is selected in the basemap gallery widget.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe the issue could be due to one of the following reasons:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The basemap triggered by dark mode is not properly loaded.&lt;/LI&gt;&lt;LI&gt;There may be a better method to update the basemap on the map.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;Here's the code I use to change the basemap. The change is reflected on the webpage, but the basemap gallery widget shows nothing selected:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;                const basemapSource = darkBasemap
                    ? await getBasemapSource(darkBasemap)
                    : mapViewOriginalBasemaps.current[currentJimuMapViewId.current];

                if (basemapSource &amp;amp;&amp;amp; bmViewModel?.current?.activeBasemap) {
                    bmViewModel.current.set('activeBasemap', basemapSource)&lt;/LI-CODE&gt;&lt;P&gt;Any help on resolving this issue would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2024 07:59:44 GMT</pubDate>
    <dc:creator>JonathanAttard</dc:creator>
    <dc:date>2024-07-25T07:59:44Z</dc:date>
    <item>
      <title>Changing BaseMap from code</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/changing-basemap-from-code/m-p/1509763#M13872</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm currently working on a dark mode feature in ArcGIS Experience Builder (ExB) Developer that automatically changes the basemap. I've also integrated a basemap gallery widget within the map widget to provide more basemap options. Selecting a basemap from the gallery and toggling between dark modes works fine, however, there's an issue when toggling dark mode directly: the basemap gallery widget shows no basemap as selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case 1:&lt;/P&gt;&lt;P&gt;Select a light mode basemap &lt;SPAN&gt;from the basemap gallery&lt;/SPAN&gt;.&lt;BR /&gt;Select a dark mode basemap from the basemap gallery aswell.&lt;BR /&gt;Toggle dark mode.&lt;/P&gt;&lt;P&gt;In this case, everything works well and the correct basemap is shown in the gallery.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case 2:&lt;/P&gt;&lt;P&gt;Directly toggle dark mode.&lt;/P&gt;&lt;P&gt;In this scenario, no basemap is selected in the basemap gallery widget.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe the issue could be due to one of the following reasons:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The basemap triggered by dark mode is not properly loaded.&lt;/LI&gt;&lt;LI&gt;There may be a better method to update the basemap on the map.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;Here's the code I use to change the basemap. The change is reflected on the webpage, but the basemap gallery widget shows nothing selected:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;                const basemapSource = darkBasemap
                    ? await getBasemapSource(darkBasemap)
                    : mapViewOriginalBasemaps.current[currentJimuMapViewId.current];

                if (basemapSource &amp;amp;&amp;amp; bmViewModel?.current?.activeBasemap) {
                    bmViewModel.current.set('activeBasemap', basemapSource)&lt;/LI-CODE&gt;&lt;P&gt;Any help on resolving this issue would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 07:59:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/changing-basemap-from-code/m-p/1509763#M13872</guid>
      <dc:creator>JonathanAttard</dc:creator>
      <dc:date>2024-07-25T07:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Changing BaseMap from code</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/changing-basemap-from-code/m-p/1524975#M14400</link>
      <description>&lt;P&gt;I managed to solve it.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 09:08:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/changing-basemap-from-code/m-p/1524975#M14400</guid>
      <dc:creator>JonathanAttard</dc:creator>
      <dc:date>2024-08-21T09:08:50Z</dc:date>
    </item>
  </channel>
</rss>

