I've been developing an application where I'd like to lay a basemap gallery of maps on top of a hillshade and topped off with a layer showing regional boundaries, building this on the code sample for the BasemapGallery button, where the button allows the user to select one of the basemaps. Within the init() function, the hillshade is added first as an ArcGISImageServiceLayer, then the BasemapGallery is built using image services with the opacity set to 0.78. Finally, an ArcGISDynamicMapServiceLayer adds the regional boundaries. When the map is first drawn, the hillshade and regional boundaries are shown but as soon as a layer is chosen from the menu button, the hillshade is no longer visible (though regional boundaries persist).
Any suggestions greatly appreciated; code shown below. Perhaps BasemapGallery isn't the right choice here?
Crile
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /> <title> Odonata Habitat Maps </title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.7/js/dojo/dijit/themes/claro/claro.css">
var url = "http://v-arcgis:8399/arcgis/rest/services/Maps/Odonata/MapServer"; var dynamicMapLayer = new esri.layers.ArcGISDynamicMapServiceLayer(url); map .addLayer(dynamicMapLayer); dojo.connect(map, 'onLoad', function(map) { //resize the map when the browser resizes dojo.connect(dijit.byId('map'), 'resize', map,map.resize); });
} function createBasemapGallery(){
// Manually create a list of basemaps to display var basemaps = []; var anax = new esri.dijit.Basemap({ layers: [new esri.dijit.BasemapLayer({ url:"http://v-arcgis:8399/arcgis/rest/services/Dragonfly/anax/ImageServer", opacity: 0.78 })], id: "anaxImage", title: "Anax papuensis" }); basemaps.push(anax);
basemapGallery = new esri.dijit.BasemapGallery({ showArcGISBasemaps: false, basemaps: basemaps, map: map }); //BasemapGallery.startup isn't needed because we aren't using the default basemap, instead //we are going to create a custom user interface to display the basemaps, in this case a menu. dojo.forEach(basemapGallery.basemaps, function(basemap) { //Add a menu item for each basemap, when the menu items are selected dijit.byId("bingMenu").addChild(new dijit.MenuItem({ label: basemap.title, onClick: dojo.hitch(this, function() { this.basemapGallery.select(basemap.id); }) })); }); }