function createBasemapGallery() { var basemapGallery = new BasemapGallery({ showArcGISBasemaps: true, map: map }); connect.connect(basemapGallery, 'onLoad', function () { array.forEach(basemapGallery.basemaps, function (basemap) dom.byId('basemapMenu').addChild(new dijit.MenuItem({ label: basemap.title, onClick: lang.hitch(this, function(){ this.basemapGallery.select(basemap.id); }) })); }); }); }
Solved! Go to Solution.
if (basemapGallery.showArcGISBasemaps) { basemapGallery.on("load", function() { createBasemapGallery(); }); } else { createBasemapGallery(); }