I had a similar problem setting the basemap using map.setBasemap and stumbled on this thread. After a bit of investigation I discovered that when using a webmap the map object holds a reference to the initial basemap as 'defaultBasemap'. You can see that by examining map.layerIds. As long as that layer remains in the map, setting a new basemap with `map.setBasemap('topo')` will not work properly. The new layer gets added, but the 'defaultBasemap' layer remains. The easiest solution is removing the 'defaultBasemap' layer just before setting a new basemap. Here's how I achieved it: const baseMap = map.getLayer('defaultBasemap');
if( baseMap ) {
map.removeLayer(baseMap);
}
map.setBasemap('streets');
... View more