3

I'm getting an error when trying to switch basemaps in my application(right now only works in IE9).

TypeError: Unable to get value of the property '_basemapGalleryLayerType': object is null or undefined

I'm using standard code provided in the ESRI samples. The full code is a mashup of various samples, so my error may be in the order I've placed things. However, I've tried reordering the code and haven't had any luck.

When I remove mapReady from the dojo.connect(map, "onLoad", mapReady); listener, the basemap gallery works, however it causes my initial basemap to fail and the mapReady function to fail as well (obviously). There is no link that I can determine between the initial basemaps and my mapReady function so I'm not sure what the deal is there...

Also, if I clear the browser cache the entire app will work, 1 time only, then on refresh, it fails as described above. Very inconsistent behavior.

Any help would be greatly appreciated.

1 Answer 1

2

This works for me:

function createBasemapGallery() {
        // Add the basemap gallery
        basemapGallery = new esri.dijit.BasemapGallery({showArcGISBasemaps: true, map: globals.map}, "basemapGallery");
        basemapGallery.startup(); 
        dojo.connect(basemapGallery, "onError", function(msg) {console.log(msg)});
      }

Then, inside init() function and after creating the map:

createBasemapGallery();
dojo.connect(map, 'onLoad', function(theMap) {
    dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
}

Then on the HTML:

<div dojoType="dijit.layout.ContentPane" style="width:380px; height:280px; overflow:auto;">
    <div id="basemapGallery" ></div>
</div>
1
  • does this work for you in general, or were you able to edit my code and get the app to work?
    – Craig
    Dec 3, 2012 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.