jaromzenger

build basemap gallery without the ArcGISBasemaps

Discussion created by jaromzenger on Sep 28, 2011
Latest reply on Feb 2, 2015 by deriven
Hi,

I'm trying to build a basemap Gallery menu button without the ArcGIS basemaps and can't seem to get the following code to work.

[HTML]            /* New Basemap */
    var newBaselayer = new esri.dijit.BasemapLayer({url: "http://mapserv.utah.gov/ArcGIS/rest/services/UtahBaseMap-Imagery2009/MapServer"});
    var newBasemap = new esri.dijit.Basemap({layers: [newBaselayer],title: "2009 images"});
    basemaps.push(newBasemap);
     /* New Basemap */
    var hybridLayer = new esri.dijit.BasemapLayer({url: "http://mapserv.utah.gov/ArcGIS/rest/services/UtahBaseMap-Hybrid/MapServer"});
    var hybridLayerNew = new esri.dijit.Basemap({layers: [hybridLayer],title: "Hybrid 2009"});
    basemaps.push(hybridLayerNew);
    /* Create Gallery and Populate Drop Down Menu */
        basemapGallery = new esri.dijit.BasemapGallery({
          showArcGISBasemaps: false, basemaps:basemaps,
          map: map
        },"basemapGallery");

        
        dojo.connect(basemapGallery,"onLoad",function(){
         dojo.forEach(basemapGallery.basemaps, function(basemap) {            
          //Add a menu item for each basemap, when the menu items are selected
          dijit.byId("basemapMenu").addChild(new dijit.MenuItem({
            label: basemap.title,
            onClick: dojo.hitch(this, function() {
              this.basemapGallery.select(basemap.id);
            })
          }));
        });
        });[/HTML]

When I set the BasemapGallery option "showArcGISBasemaps" to false, the drop down menu should only populate with the basemaps that I've defined, but it doesn't show anything. When I set the BasemapGallery "showArcGISBasemaps" to true, the drop down menu populates with the ArcGIS Basemaps and the ones I've defined. Could someone please instruct me in how to populate the dropdown menu with just the basemaps I've defined?

Thanks

Outcomes