Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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>
share|improve this answer
    
does this work for you in general, or were you able to edit my code and get the app to work? –  Craig Dec 3 '12 at 13:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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