I have an application using the arcgisUtils.createMap method. In the application, properly formatted WebMapJson is passed into the createMap() method and a working map is returned. However, I have a problem with the returned map when accessing the map.basemapLayerIds property or using map.getBasemap() and map.setBasemap(). Basically, in the response map the basemapLayerIds property is null, which affects the getBasemap() and setBasemap() methods.
Further, if I do call the map.setBasemap() method a second basemap will get added to the map underneath the original basemap that was uspplied in the JSON.
This Esri JS API sample has the same issue from what I can tell. Run this sample in debug mode and put a breakpoint before the legend is started (or change the map to a global variable) and test the basemapLayerId property and getBasemap() method.
Is this an oversight in the JS API?
In the meantime, to get around this issue, I'm just traversing the WebMapJson in my code and if the baseMapLayers array is populated then I am manually populating the response Map's basemapLayerIds array.
Any insight is much appreciated!