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.

asked Nov 28, 2012 at 13:30

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>
answered Nov 28, 2012 at 16:29
1
  • does this work for you in general, or were you able to edit my code and get the app to work? Commented Dec 3, 2012 at 13:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.