Regarding your first solution, adding them individually, I'm assuming you're referring to something like this?
require([
"esri/dijit/Basemap", ...
], function(Basemap, ... ) {
var basemaps = [];
var waterBasemap = new Basemap({
layers: [waterTemplateLayer],
title: "Water Template",
thumbnailUrl: "images/waterThumb.png"
});
basemaps.push(waterBasemap);
...
});
On the same API reference page (BasemapGallery | API Reference | ArcGIS API for JavaScript), there's some info on calling a basemap gallery group:
require([
"esri/map", "esri/dijit/BasemapGallery", "dojo/dom-construct", ...
], function(Map, BasemapGallery, domConstruct, ... ) {
var map = new Map( ... );
var basemapGallery = new BasemapGallery({
showArcGISBasemaps: true,
basemapsGroup: { owner: "esri", title: "Community Basemaps" },
map: map
}, domConstruct.create('div'));
...
});
According to the documentation:
The group can be defined by specifying either the id or the owner and title of the group. If all three parameters are defined only the id is used. If a valid basemapsGroup is defined then the value of showArcGISBasemaps is ignored and the default ArcGIS.com basemaps are not displayed. |