evtguy

glitch/change to basemapGallery under v3.4

Discussion created by evtguy on Apr 10, 2013
Just came across this. We have a development sever within our organization (let's call it DMC) that is used for development web maps. I've mostly used v2.8 of the API but recently upgraded one app to v3.3

Yesterday I started developing a completely new app using one of the ESRI v3.4 samples as a starting point. I finally got around to adding in the basemap selection dropdown button as shown in this ESRI sample. I've modified it slightly but my modified version has run fine under v2.8 and v3.3:

 var map, initExtent, basemapGallery;

                basemapGallery = new esri.dijit.BasemapGallery({
   showArcGISBasemaps: true,
   map: map
 });

  
 //Manually add the USGS Topo basemap into the basemap gallery
 var usgsLayer = new esri.dijit.BasemapLayer({
   url: "http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer"
 });
 var usgsBasemap = new esri.dijit.Basemap({
  layers: [usgsLayer],
  title: 'USGS Topoography'
 });
 
 basemapGallery.add(usgsBasemap);
 
 // 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);})
   }));
  }
  }); 
 });


When I just added this code into my v3.4 based app, it would throw an error during the "new esri.dijit.BasemapGallery" line of code. Under IE, it would just say "Access Denied" but Firefox returned:

 "Error: Permission denied for <file://> to create wrapper for object of class UnnamedClass
http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/
Line 15"


I spent some time verifying that my code hadn't copy/pasted wrong and then zero'd in on the reference to "file" in the Firefox error. In the address bar of my browser, the path to the HTML was a UNC format path ala "\\dmc\appName\index.html" but the minute I changed the URL to "http:\\dmc\appName\" the basemapGallery no longer threw an error. and loaded successfully.

Very strange. This did not throw an error in previous versions of the API.

Steve

Outcomes