Select to view content in your preferred language

build basemap gallery without the ArcGISBasemaps

4971
6
09-28-2011 11:00 AM
jaromzenger
New Contributor
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
0 Kudos
6 Replies
derekswingley1
Frequent Contributor II
Have you tried specifying thumbnailUrl when creating your Basemaps?
0 Kudos
jaromzenger
New Contributor
No, I didn't think I needed to do anything with thumbnails since I'm building a dropdown menu with just a list of basemap titles.
0 Kudos
derekswingley1
Frequent Contributor II
0 Kudos
jaromzenger
New Contributor
Yes, that should work. Thank you very much.
Can you explain the changes you made in order for this to work?
0 Kudos
derekswingley1
Frequent Contributor II
I started with this sample:  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/widget_basemapbutton.html

Removed some of the fluff and then used links to your map services...the code is all there in the JS Fiddle link. I'm honestly not sure what the difference is between the code in the fiddle and what you posted.
0 Kudos
DerivenC
New Contributor II

For future reference, difference is that the "onLoad" or on('onload') are not needed.  Neither is the startup().

Current location of the sample is here:

Display Bing maps in basemap gallery | ArcGIS API for JavaScript

0 Kudos