AnsweredAssumed Answered

basemap selection using basemapgallery dijit

Question asked by bforbhavin on Apr 13, 2015

Few questions about BaseMap and BaseMapGallery dijit:

 

I am using BaseMapGallery to retrieve all basemaps available on ArcGIS.com following way.

 

  var vBasemapGallery = new BasemapGallery({

                       showArcGISBasemaps: true,

                       map: myMap

  });

 

Once all basemaps are loaded, I show them in one popup of my application.

 

vBasemapGallery.on('load', function() {

        //here I open up the popup of my code, display all basemaps and handle selection of the basemap.

       // I write callback function here to handle the selection 

  },

 

I receive the selected basemap item in my callback function once user switches to the another basemap. So far everything is good. Now, questions here are:

 

1) Is it okay to use following code in the callback function?

 

vBasemapGallery.map.setBasemap(selectedbasemap); //e.g. topo, streets, ocean etc.

 

2) BaseMapGallery handles this event automatically if the dijit is used as it is. How this is going to be different than #1 here? I looked at the obfuscated code and it looks like handling few validations, calculations etc. If I do setBaseMap as mentioned in #1 then will that be buggy code?

 

3) When I get all basemaps from ArcGIS.com, it doesn't have any id that can give values like 'streets', 'topo' etc. How can we know based on the object that the selected basemap is 'streets' let's say. Should we compare with the Title? Title is in English so, is it going to be the same always?

 

 

 

Outcomes