Select to view content in your preferred language

layer transparency not working

5307
9
04-04-2011 06:02 AM
glennhazelton
Deactivated User
in my .msd file i have a polygon layer set to 50% transparency.
when i turn it on in the flex 2.2 viewer it is not transparent.
in the rest/services list the transparency is recorded.
any thoughts about why this happening??
thanks
Tags (2)
0 Kudos
9 Replies
JonFisher
Emerging Contributor
in my .msd file i have a polygon layer set to 50% transparency.
when i turn it on in the flex 2.2 viewer it is not transparent.
in the rest/services list the transparency is recorded.
any thoughts about why this happening??
thanks


Transparency set in the mxd / msd only applies to layers WITHIN your map service. For the entire map service to be transparent (e.g. to show the base map through your service) you need to set an alpha value of less than 1 (1 is 100% opaque, 0 is 100% transparent) for your map service. If you only have a single layer in your map service you should turn off that 50% transparency as it serves no real purpose and may slow things down.
0 Kudos
IvanBespalov
Frequent Contributor
If you only have a single layer in your map service you should turn off that 50% transparency as it serves no real purpose and may slow things down.


That is not good idea.

Read Flex API reference for ArcGISDynamicMapServiceLayer

imageFormat:String property
The output image type. Valid types are: png8 | png24 | png32 | jpg | gif. Only png and gif formats support transparency.
The default value is png8.


Set imageFormat value to png32 and you see the same transparency as you set in mxd.

It looks like:

var dynLayer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(url);
// set properties
dynLayer.imageFormat = "PNG32";
// add layer to map
map.addLayer(dynLayer);


or:

<esri:Map id="myMap">
     <esri:ArcGISDynamicMapServiceLayer id="dynamicLayer"
       imageFormat="png32"
       url="{dynamicLayerUrl}"/>
</esri:Map>
0 Kudos
glennhazelton
Deactivated User
Set imageFormat value to png32 and you see the same transparency as you set in mxd.

i am not sure how to set this in the config.xml file for the flex viewer. i am not running custom code.
i like the idea but don't know how to do it.
can you enlighten me?
0 Kudos
IvanBespalov
Frequent Contributor
config.xml file contains information about layers configuration

something like this:
<basemaps>
     <layer label="Streets" type="tiled" visible="true"  alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
     <layer label="Aerial"  type="tiled" visible="false" alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
     <layer label="Topo"    type="tiled" visible="false" alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
</basemaps>
<operationallayers>
     <layer label="Boundaries and Places" type="tiled" visible="false"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer"/>
     <layer label="Fires" type="feature" visible="false" alpha="1"
          info="widgets/InfoTemplates/SimpleInfoWinWidget.swf"
          infoconfig="widgets/InfoTemplates/IWT_Fires.xml"
          url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0"/>
</operationallayers>


add imageFormat property to your layer:
<basemaps>
     <layer label="Streets" type="tiled" visible="true"  alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
     <layer label="Aerial"  type="tiled" visible="false" alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
     <layer label="Topo"    type="tiled" visible="false" alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
</basemaps>
<operationallayers>
     <layer label="Boundaries and Places" type="tiled" visible="false"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer"/>
     <layer label="Fires" type="feature" visible="false" alpha="1"
          info="widgets/InfoTemplates/SimpleInfoWinWidget.swf"
          infoconfig="widgets/InfoTemplates/IWT_Fires.xml"
          url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0"/>
     <layer label="MyLayer" 
          type="dynamic" 
          visible="true"
          imageFormat="png32"
          url="my layer url"/>
</operationallayers>


Find MapManager.mxml in FlexViewer. This file contains layes adding business logic.
As you see, only such types of layers support imageFormat proprty: "dynamic", "image", "arcims", "wms".
You can change/add this property in this file.

More information in Flex API reference.
0 Kudos
glennhazelton
Deactivated User
thanks this is great!
0 Kudos
AndrewHargreaves
Deactivated User
Hi,
I am trying to display an operational sub-layer that is set at 50% transparency in my MXD. Within the MXD I have set 'Use Color Transparency' in the MSD, but my REST service for this layer (sub-layer 1 below) indicates transparency on this layer is 0. Below is my code I use in the FlexViewer config:

        
<operationallayers>
    <layer label="Meters" type="dynamic" visible="true"
             imageFormat="png32"
             url="http://ags2.cdm.com/arcgis/rest/services/Meters/MapServer">
                <sublayer id="0" popupconfig="popups/PopUp_AMR.xml"/>
                <sublayer id="1" popupconfig="popups/PopUp_AMR_PressureZones.xml"/>
    </layer>
</operationallayers>
0 Kudos
FrankRoberts
Frequent Contributor

Find MapManager.mxml in FlexViewer. This file contains layes adding business logic.
As you see, only such types of layers support imageFormat proprty: "dynamic", "image", "arcims", "wms".
You can change/add this property in this file.

More information in Flex API reference.


I'm looking at MapManager.mxml at around line 550, and it looks like ESRI it is trapping for imageFormat, however it is not working.  I assume "if (imageFormat)" is to pick up on if you have "imageFormat="png32"" in your config.  But it doesn't look like it is finding it.

Around line 544 I added:
dynLayer.imageFormat = "png32"

And now transparency works!  Thanks for the above post.  I hope ESRI will catch this in the next release.
0 Kudos
DasaPaddock
Esri Regular Contributor
All the tags and attributes in the config xml should be lowercase. Try using imageformat="png32".
0 Kudos
Nicholas_Hansen
New Contributor
config.xml file contains information about layers configuration 

something like this: 
<basemaps>
     <layer label="Streets" type="tiled" visible="true"  alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
     <layer label="Aerial"  type="tiled" visible="false" alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
     <layer label="Topo"    type="tiled" visible="false" alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
</basemaps>
<operationallayers>
     <layer label="Boundaries and Places" type="tiled" visible="false"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/..."/>
     <layer label="Fires" type="feature" visible="false" alpha="1"
          info="widgets/InfoTemplates/SimpleInfoWinWidget.swf"
          infoconfig="widgets/InfoTemplates/IWT_Fires.xml"
          url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0"/>
</operationallayers>


add imageFormat property to your layer: 
<basemaps>
     <layer label="Streets" type="tiled" visible="true"  alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
     <layer label="Aerial"  type="tiled" visible="false" alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
     <layer label="Topo"    type="tiled" visible="false" alpha="1"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
</basemaps>
<operationallayers>
     <layer label="Boundaries and Places" type="tiled" visible="false"
          url="http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/..."/>
     <layer label="Fires" type="feature" visible="false" alpha="1"
          info="widgets/InfoTemplates/SimpleInfoWinWidget.swf"
          infoconfig="widgets/InfoTemplates/IWT_Fires.xml"
          url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0"/>
     <layer label="MyLayer" 
          type="dynamic" 
          visible="true"
          imageFormat="png32"
          url="my layer url"/>
</operationallayers>


Find MapManager.mxml in FlexViewer. This file contains layes adding business logic. 
As you see, only such types of layers support imageFormat proprty: "dynamic", "image", "arcims", "wms". 
You can change/add this property in this file. 

More information in Flex API reference.


If you are editing the config.xml file for Flex Viewer 2.4 note this correction to the above code reference: Use lowercase like this; imageformat="png32"
0 Kudos