I am attempting to add a BasemapGallery to my web application. I prefer to create my layout dynamically using constructors such as:
layout.cpRight = new ContentPane({
region:"right",
...
...
});
layout.borderContainer.addChild(layout.cpRight);
This is functioning fine and my layout is placed as it should.
The probleme is When I attempt to add basemapGallery with the bellow code:
maps.basemapGalleryParams = {
showArcGISBasemaps:true,
map: maps.map,
};
maps.basemapGallery = new BasemapGallery(maps.basemapGalleryParams,layout.cpRight);
maps.basemapGallery.startup();
I get the following Error Code: init.js.160
Error: Tried to register widget with id==dijit_layout_ContentPane_0 but that id is already registered(…) "in domReady callback" "Error: Tried to register widget with id==dijit_layout_ContentPane_0 but that id is already registered
I originally declared ids inside of the widget constructors parameter but removed when I got this error. The results where the same.
A few web searches indicate this can be a fairly common problem with some "easy" solutions but I have not found a solution where the layout is declared programaticly as I would like to. It seems many defer to declare components in HTML.
Side note: I break out applications into multiple scripts thus I create arrays to ensure certain variables are global across all scripts. Hence why in the scripts above, things are not being declared with the var keyword, but rather directly appending to the array.