Select to view content in your preferred language

Changing BaseMap from code

189
1
Jump to solution
07-25-2024 12:59 AM
JonathanAttard
Occasional Contributor

Hi,

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.

 

Case 1:

Select a light mode basemap from the basemap gallery.
Select a dark mode basemap from the basemap gallery aswell.
Toggle dark mode.

In this case, everything works well and the correct basemap is shown in the gallery.

 

Case 2:

Directly toggle dark mode.

In this scenario, no basemap is selected in the basemap gallery widget.

 

I believe the issue could be due to one of the following reasons:

  • The basemap triggered by dark mode is not properly loaded.
  • There may be a better method to update the basemap on the map.


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:

                const basemapSource = darkBasemap
                    ? await getBasemapSource(darkBasemap)
                    : mapViewOriginalBasemaps.current[currentJimuMapViewId.current];

                if (basemapSource && bmViewModel?.current?.activeBasemap) {
                    bmViewModel.current.set('activeBasemap', basemapSource)

Any help on resolving this issue would be greatly appreciated.

Thank you!

0 Kudos
1 Solution

Accepted Solutions
JonathanAttard
Occasional Contributor

I managed to solve it.

View solution in original post

0 Kudos
1 Reply
JonathanAttard
Occasional Contributor

I managed to solve it.

0 Kudos