When I use the basemap gallery to select an arcgis basemap upon map load, I get 30-40 errors like Cannot read property 'mapDiv_layer0_tile_4_2_7' of null.This seems to be because of a 0-length timeout that is requested when the original basemap is added, whose callback tries to access the tiles for that basemap which has already been replaced, (there's a new layer in its place). This doesn't happen if I choose a non-arcgis basemap like a Bing basemap.
Can anyone tell me what is causing this and offer a solution to fix it?
I have already tried not loading an initial basemap and using the basemap gallery to load the first basemap, but this does not work (no basemap is loaded, but no errors).
If someone knows how to check if the requested basemap is an esri basemap without hard-coding the name or id or anything else, I would like to know that too, since i could load esri maps another way (on map initialization or by manually adding a layer).
Thanks for your help!