Select to view content in your preferred language

Is it possible to use BasemapToggle with custom basemaps?

3545
1
10-11-2013 09:50 AM
CraigMcDade
Occasional Contributor III
I have two custom basemaps that I want to use in my app using BasemapToggle. Is this possible? The blog suggests it is but I haven't seen a sample or any documentation on how to do it properly.
0 Kudos
1 Reply
ERNESTOGIRON
New Contributor
There is not too much documentation about it but it is possible.

Just include the class "esri/config" and add your custom maps similar like:

require([
  "esri/map", 
  "esri/dijit/BasemapToggle", 
  "esri/config",
  "dojo/domReady!"
], function(
  Map, BasemapToggle, esriConfig
)  {
  
   esriConfig.defaults.map.basemaps.delorme = {
    baseMapLayers: [
      { url: "http://services.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer" }
    ],
    title: "Delorme"
  };


Next you can include it into your BasemapToogle class as follow:
toggle = new BasemapToggle({
  map: map,
  basemap: "delorme",
  basemaps: {
    delorme: {
      label: "delorme",
      url: "http://www.delorme.com/images/homepage/dbm_icon.jpg"
    }, topo: {
      label: "topo",
      url: "http://js.arcgis.com/3.7/js/esri/dijit/images/basemaps/topo.jpg"
    }
  }
}, "BasemapToggle");
toggle.startup();


That's it, if you want to see a working demo go to jsbin: http://jsbin.com/iFakeLa/1

I saw this solution of couple of days written by Derek Swingley at
http://gis.stackexchange.com/questions/74154/how-to-use-custom-basemaps-with-basemaptoggle-widget

I hope it helps!!!

Best,
Ernesto Giron
GIS/RS Analyst/Developer/Consultant
http://ernestogiron.blogspot.com
0 Kudos