Webmap basemap opacity not honoured

951
10
Jump to solution
08-13-2012 02:04 AM
SamLarsen
New Contributor III
I am consuming a webmap which has an opacity setting for the Bing imagery basemap.  The opacity value is being passed from ArcGIS Online in the webmap JSON but the arcgis utils library is not honouring this opacity value.
esri.arcgis.utils.createMap


The webmap JSON in question is this:

    "baseMap": {         "baseMapLayers": [{             "id": "BingMapsAerial",             "opacity": 0.8200000000000001,             "visibility": true,             "type": "BingMapsAerial"         }],         "title": "Bing Maps Aerial"     },     "widgets": {         "editor": {}     },     "version": "1.6"


I am using version 3.0 of the JavaScript API.

I have reproduced this issue in the following sample:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/ags_createwebm...
Using the following webmap:
http://www.arcgis.com/home/webmap/viewer.html?webmap=b106b3fa92f041668f967b1223cffbeb

Is this a known limitation? Or is this the remnants of the following bug that has not been fixed?
http://forums.arcgis.com/threads/35759-How-to-set-BaseMapLayer-opacity?highlight=bing+opacity
0 Kudos
1 Solution

Accepted Solutions
__Rich_
Occasional Contributor III
If I hack this into the _initLayer method:
layer = new esri.virtualearth.VETiledLayer({         bingMapsKey: options.bingMapsKey,         mapStyle: style,         id: layerObject.id,         opacity:layerObject.opacity });

Then the opacity is obeyed, looks like someone missed it, or perhaps they've attempted to set it somewhere else, anyway hope that helps getting a proper fix in place 🙂

edit: looking at the code for the other layer types, that is the 'consistent' place for it.

Guess someone forgot to include it for VETiledLayer...

View solution in original post

0 Kudos
10 Replies
__Rich_
Occasional Contributor III
(you'll have to forgive me if this isn't what you mean, I'm not overly familiar with the arcgis.com stuff)

When I view:

http://www.arcgis.com/home/webmap/viewer.html?webmap=b106b3fa92f041668f967b1223cffbeb

I see the base map with an opacity of 0.73, so to me it looks like the opacity value is being honoured.  (I assume you've changed it from 0.8200000000000001?!)

Have I missed the point?
0 Kudos
SamLarsen
New Contributor III
The webmap that i linked to is to be used as a test webmap to be consumed in the JavaScript API as shown in the sample that i also linked to:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/ags_createwebm...

Therefore, a small amount of coding will be needed to embed the test webmap in the sample page in order to properly test for the bug.
The results you saw were expected - the webmap does honour the basemap transparency when viewed in the ArcGIS.com viewer.  It is not however honoured when the sample webmap is embedded in the sample page listed above.
0 Kudos
__Rich_
Occasional Contributor III
The webmap that i linked to is to be used as a test webmap to be consumed in the JavaScript API as shown in the sample that i also linked to:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/ags_createwebm...

Therefore, a small amount of coding will be needed to embed the test webmap in the sample page in order to properly test for the bug.
The results you saw were expected - the webmap does honour the basemap transparency when viewed in the ArcGIS.com viewer.  It is not however honoured when the sample webmap is embedded in the sample page listed above.

Ah, I see - knew I'd get the wrong end of the stick - first time I've tried one of these things 🙂

Just setup the sample locally and pointed it at the webmap and you're right it's 100% opaque.

Might just have a little trawl through the source code to see if the opacity is being ignored/overridden/mangled etc.
0 Kudos
__Rich_
Occasional Contributor III
If I hack this into the _initLayer method:
layer = new esri.virtualearth.VETiledLayer({         bingMapsKey: options.bingMapsKey,         mapStyle: style,         id: layerObject.id,         opacity:layerObject.opacity });

Then the opacity is obeyed, looks like someone missed it, or perhaps they've attempted to set it somewhere else, anyway hope that helps getting a proper fix in place 🙂

edit: looking at the code for the other layer types, that is the 'consistent' place for it.

Guess someone forgot to include it for VETiledLayer...
0 Kudos
__Rich_
Occasional Contributor III
Did that answer your question, Sam?
0 Kudos
SamLarsen
New Contributor III
Rich,

On which object is the _initLayer method?

Sam
0 Kudos
__Rich_
Occasional Contributor III
Rich,

On which object is the _initLayer method?

Sam

esri.arcgis.utils i.e. it's a bug in the JS API.
0 Kudos
SamLarsen
New Contributor III
Rich,

I found that method and implemented the fix locally and it does work.
I am logging the bug and will post a bug reference when i get it.

Thanks,
Sam
0 Kudos
__Rich_
Occasional Contributor III
Rich,

I found that method and implemented the fix locally and it does work.
I am logging the bug and will post a bug reference when i get it.

Thanks,
Sam

Sam,

Cool - glad to have been of some help 🙂

Rich
0 Kudos