AndyMan

BasmapGallery,,,  Basemaps from two different locations?

Discussion created by AndyMan on May 21, 2012
Latest reply on May 23, 2012 by AndyMan
Hello,

I have a locally installed server which puts out geospatial content on an intranet setup. I have a number of different services which are consumed by folks in the office.

I am working on taking the BasemapGallery (dropdown example from the APIs) and have three services which are candidates for my dropdown. I have been able to put the services/basemaps together in the gallery and can switch between them IF THEY COME FROM THE SAME LOCATION ON THE SERVER..

Specifically, I have two which are located in Folder "A" and if I list them first in my code they will both open and display. However, the service which is in Folder "B" will only show its "Title" on the dropdown, but will not display. If I swap the services around, ie put the service in Folder "B" First... then it will display but not the services listed in Folder "A".

Is there a quick fix for this? or do I have to put code in to destroy/build dynamically the BasemapGallery based upon the DropDown Selection event? My code below.. ..

function createBasemapGallery(){
//Manually creating a list of basemaps to display
var basemaps = [];
var myStreets = new esri.dijit.BasemapLayer({url: "http://myLittleServer/rest/services/Folder_A/MapServer"});
var theStreets = new esri.dijit.Basemap({layers: [myStreets], title: "The StreetNetwork"});
basemaps.push (theStreets);

var myHouses = new esri.dijit.BasemapLayer({url: "http//myLittleServer/rest/services/Folder_B/MapServer"});
var theHouses = new esri.dijit.Basemap({layers:[myHouses], title: "The Houses"});
basemaps.push (theHouses);

basemapGallery = new esri.dijit.BasemapGallery({
showArcGISBasemaps: false,
basemaps: basemaps,
bingMapskey: bingKey,
map: map
});
//BasemapGallery.startup isnt 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);
})
}));

Outcomes