I agree that this is frustrating. Instead of "showArcGISBasemap" being true/false I wish it would take an array of maps to include
As a work around, you can set it to false, and then manually build your Gallery. Just create a Basemap (using the REST url of the basemap you want to include) for each and than manually load the Gallery.
// Populate the basemap gallery widget with the list of ESRI basemaps
dojo.connect(basemapGallery, 'onLoad', function () {
//add the basemaps to the menu but exclude the "Oceans" basemap
dojo.forEach(basemapGallery.basemaps, function (basemap) {
if (basemap.title != 'Oceans') {
dijit.byId("basemapMenu").addChild(new dijit.MenuItem({
label: basemap.title,
onClick: dojo.hitch(this, function () {this.basemapGallery.select(basemap.id);})
}));
}
});
});Am I missing the point of your issue? Here's a slightly modified snippit of ESRI sample code that I use to load my basemapGallery widget with the ESRI basemaps with the exception of the Oceans basemap:// Populate the basemap gallery widget with the list of ESRI basemaps dojo.connect(basemapGallery, 'onLoad', function () { //add the basemaps to the menu but exclude the "Oceans" basemap dojo.forEach(basemapGallery.basemaps, function (basemap) { if (basemap.title != 'Oceans') { dijit.byId("basemapMenu").addChild(new dijit.MenuItem({ label: basemap.title, onClick: dojo.hitch(this, function () {this.basemapGallery.select(basemap.id);}) })); } }); });
It's in legacy code. Sorry.
Steve
hideDumbLayers: function(){
//if created
if(dojo.byId("galleryNode_basemap_0")){
//find current layer
for(var j = 0; j < this.map.layerIds.length; j++) {
var layer = this.map.getLayer(this.map.layerIds);
if(layer.visible==true&&dojo.indexOf(this.mcgisBasemaps,layer.id)>-1){
if(layer.id=="Base Map"){
this.initBasemap="MCGIS Base Map";
}else{
this.initBasemap=layer.id;
}
}
}
var dumbBasemapIds=[];
var ids={};
var galleryContainer=dojo.byId("galleryNode_basemap_0").parentNode;
dojo.forEach(galleryContainer.childNodes, dojo.hitch(this, function(galleryItem){
if(galleryItem.childNodes[1]){
var title = galleryItem.childNodes[1].childNodes[0].title;
if(title==="Oceans"||title==="Light Gray Canvas"||title==="Relief with Labels"||title==="Terrain"||title==="Terrain with Labels"||title==="Shaded Relief"){
dumbBasemapIds.push(galleryItem.id);
}else{
ids[title]=galleryItem.id;
if(title==this.initBasemap){
this.baseMapGallery.select(ids[title].replace("galleryNode_",""));
dojo.addClass(dojo.byId(ids[title]), "esriBasemapGallerySelectedNode");
}
}
}}));
this.layerIds=ids;
dojo.forEach(dumbBasemapIds, dojo.hitch(function(id){
dojo.style(dojo.byId(id), "display", "none");
}));
}else{
setTimeout(dojo.hitch(this, function() { this.hideDumbLayers(); } ), 50);
}
}
}
Right.
I create my basemap, then call a method (sorry devs) called "hideDumbLayers", which hides (but does not remove because it breaks the gallery) the layers I do not want to show.
Jeff could you elaborate on why removing the default basemaps breaks the Gallery? I'm running into an issue where if I use 'showArcGISBasemaps : false' my dropdown menu won't populate with my custom list. It worked when I did it in a dojo title pane, but not working in a button. I'm a newb so probably it is forehead-slap kind of situation, but I am curious what is known to break.
Thanks!