I'm looking for the simplest method/example on how to set a specific ESRI basemap upon open of a widget (any one, doesn't matter) and then set it to a different specific ESRI basemap when widget closes. Always just a binary setting: basemap "x" on open, basemap "y" on close.
Thanks!
Solved! Go to Solution.
James,
Sorry I forgot about the way WAB sets the basemap for the WebMap. Here is what will work for onOpen:
onOpen: function () {
//First remove the Web Map basemap
this.map.removeLayer(this.map.getLayer(this.map.layerIds[0]));
this.map.setBasemap("dark-gray");
Do you have the basemap gallery widget in this app?
You can just use standard JS API calls like:
onOpen: function () {
this.map.setBasemap("dark-gray");
},
onClose: function () {
this.map.setBasemap("streets");
}
Thanks for the suggestion, looks promising.
I can see the request being made to the World_Dark_Gray_Base service but it doesn't change in the map display from the topo (what is saved in the web map).
James,
Sorry I forgot about the way WAB sets the basemap for the WebMap. Here is what will work for onOpen:
onOpen: function () {
//First remove the Web Map basemap
this.map.removeLayer(this.map.getLayer(this.map.layerIds[0]));
this.map.setBasemap("dark-gray");
You forget 100x's the amount of JavaScript I know.
Thanks!