Select to view content in your preferred language

Changing basemaps using activeBasemap = <basemapid> no longer works

3947
3
Jump to solution
04-05-2022 12:25 PM
MichaelSnook
Frequent Contributor

Hi All, 

Just upgraded from 4.22 to 4.23 and this setting the BaseMap Gallery widget active basemap using basemapGallery.activeBasemap = 'hybrid' (for example) fails with an error:

Uncaught TypeError: Cannot read properties of undefined (reading 'spatialReference')

I assume this has to to with the addition of allowing basemaps to have different spatial references in 4.23 but I can't seem to find and documentation on this particular issue.

Any help would be great.

Thanks.

0 Kudos
1 Solution

Accepted Solutions
AnneFitz
Esri Regular Contributor

Hi @MichaelSnook - thanks for reporting this! We're working on a fix for this bug.

In the meantime, you can set the basemap directly on the map, and the activeBasemap in the BasemapGallery will update: 

view.map.basemap = "hybrid";

View solution in original post

0 Kudos
3 Replies
AnneFitz
Esri Regular Contributor

Hi @MichaelSnook - thanks for reporting this! We're working on a fix for this bug.

In the meantime, you can set the basemap directly on the map, and the activeBasemap in the BasemapGallery will update: 

view.map.basemap = "hybrid";
0 Kudos
MichaelSnook
Frequent Contributor

Easy fix...thanks!  Although, not a huge deal but, the widget doesn't seem to show the new base map as the 'active' one (there's no blue indicator or highlight for the basemap)...it does switch fine though.

0 Kudos
AnneFitz
Esri Regular Contributor

That seems to be a bug as well - we've fixed both of these issues for version 4.24. You can try these fixes out ahead of the release with the https://js.arcgis.com/next version of the API. Let us know if you are still running into any issues. Thanks!

0 Kudos