Select to view content in your preferred language

How to set BaseMapLayer opacity?

1521
7
07-27-2011 08:53 PM
StephenLead
Honored Contributor
The reference for BasemapLayer says that it includes an opacity setting, however I'm having problems getting it to work.

Using the sample here I add a setting to specify the opacity:

function createBasemapGallery(){
        //Manually create a list of basemaps to display
        var basemaps = [];
        var basemapRoad = new esri.dijit.Basemap({
          layers: [new esri.dijit.BasemapLayer({
            type: "BingMapsRoad",
            opacity: 0.25
          })],
          id: "bmRoad",
          title: "Road"
        });


This doesn't have any discernible effect - what am I doing wrong?

Cheers,
Steve
0 Kudos
7 Replies
HemingZhu
Frequent Contributor
The reference for BasemapLayer says that it includes an opacity setting, however I'm having problems getting it to work.

Using the sample here I add a setting to specify the opacity:

function createBasemapGallery(){
        //Manually create a list of basemaps to display
        var basemaps = [];
        var basemapRoad = new esri.dijit.Basemap({
          layers: [new esri.dijit.BasemapLayer({
            type: "BingMapsRoad",
            opacity: 0.25
          })],
          id: "bmRoad",
          title: "Road"
        });


This doesn't have any discernible effect - what am I doing wrong?

Cheers,
Steve


Instead of set opacity on each basemap layer. you could try set it once: 
var baselayer = map.getLayer(youbasemapid);
baselayer.setOpacity(0.25);

if you want to set up opacity differently for each individual basemap layer, you could use the above code in layer's onSelectionChange() event
0 Kudos
derekswingley1
Deactivated User
Steve- Thanks for bringing this up, it's a bug with the basemap gallery and bing layers. We'll fix it at 2.5. Until then, can you use the workaround suggested by Heming?
0 Kudos
StephenLead
Honored Contributor
it's a bug with the basemap gallery and bing layers


Hooray, an actual bug rather than doing something wrong!

No probs, I'll use the workaround for now. Thanks guys.
0 Kudos
derekswingley1
Deactivated User
Well done Steve!
0 Kudos
derekswingley1
Deactivated User
I know we had a workaround, but we did fix this in 2.5:  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/new_v25.html
0 Kudos
StephenLead
Honored Contributor
man, you are thorough. Thanks for following up on this (I'd totally forgotten)
0 Kudos
derekswingley1
Deactivated User
Just wanted to make sure we closed the loop on this one!
0 Kudos