Turn on/off base map in 3.3?

2651
2
Jump to solution
01-22-2013 11:04 AM
HaoHu
by
New Contributor II
In 3.3, switching between different base maps can be done by setBasemap() function. But if I want to add an option---set the base map to none, is it still possible to use that function? Or is there any better way I can do that?

My code is like this,

map = new esri.Map("map",
            {
                basemap: "streets",
                extent: initExtent,
            });

How can I write the code to turn off the base map, and another code to turn on later? Thanks in advance.
0 Kudos
1 Solution

Accepted Solutions
StephenLead
Regular Contributor III
How can I write the code to turn off the base map, and another code to turn on later?


You can get a handle on the basemap using map.basemapLayerIds - by default I think it's called "layer0".

var bm = map.getLayer("layer0"); bm.setVisibility(false); //to switch off bm.setVisibility(true); //to switch on


Steve

View solution in original post

0 Kudos
2 Replies
StephenLead
Regular Contributor III
How can I write the code to turn off the base map, and another code to turn on later?


You can get a handle on the basemap using map.basemapLayerIds - by default I think it's called "layer0".

var bm = map.getLayer("layer0"); bm.setVisibility(false); //to switch off bm.setVisibility(true); //to switch on


Steve
0 Kudos
HaoHu
by
New Contributor II
Thanks Steve, that really helps!
0 Kudos