2

I am using ArcGIS server 9.3.1 Javascript API via REST.

I have two map services , one is tiled service returns a satellite image , and the other is dynamic displays the roads ,POIs and Parcels.

I'm trying to make the dynamic one shows the roads only above the satellite image , but i'm always getting white background with the roads and it covers the satellite image.

Here's my code :

map = new esri.Map("mapDiv");
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://URL_TO_SATELLITE/MapServer");
map.addLayer(basemap);

var imageParameters = new esri.layers.ImageParameters();
imageParameters.format = "png24";
imageParameters.height=100;
imageParameters.width=100;  
imageParameters.layerIds=[7]; // Only Roads !
imageParameters.layerOption = esri.layers.ImageParameters.LAYER_OPTION_SHOW;
imageParameters.transparent=true;   

var entrmap = new esri.layers.ArcGISDynamicMapServiceLayer("http://URL_TO_DYNAMIC/MapServer",
              {"imageParameters":imageParameters}); 

map.addLayer(entrmap);
1
  • can you share some json data from ArcGISDynamicMapServiceLayer("URL_TO_DYNAMIC/MapServer") Query(supported operations) in ArcGIS Services for getting some information about data..
    – urcm
    May 24, 2012 at 13:42

3 Answers 3

4
+25

If you set transparency only on one layer in your ArcMap file you should save it as MSD () and NOT mxd and in javascript init ArcGISDynamicMapServiceLayer with

imageParameters.format = "png32";

Here are some links to similair posts on ESRI forum:

http://forums.arcgis.com/threads/27413-layer-transparency-not-working

http://forums.arcgis.com/threads/10011-dynamic-layer-transparency

2
  • 1
    PNG24 delivers the transparency ... no need for PNG32
    – Mathboy
    May 27, 2012 at 5:20
  • PNG24 as it name states consists of 3 colors, each 8 bytes size. I've read somewhere that Photoshop bring this misconception, because when you save image in PS in 'png24' it saves it in 'png32'. But I might be wrong, please check it out.
    – ljader
    May 29, 2012 at 9:02
1

I think this is a setting in the mxd in arcmap I will look and see what I can find, but I think it's in the document properties.

2
  • I don't need to have it as a transparent all the time , just in case of Aerial image , i want to make the background transparent .
    – Mathboy
    May 27, 2012 at 5:23
  • @Mathboy is there a reason not to make it transparent all the time? There is no penalty really.
    – Steve
    May 29, 2012 at 23:20
0

You should use the SetVisibleLayers method on the ArcGISDynamicMapServiceLayer, to set only one layer as visible.

This Would be the Code:

map = new esri.Map("mapDiv");
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://URL_TO_SATELLITE/MapServer");
map.addLayer(basemap);

var imageParameters = new esri.layers.ImageParameters();
imageParameters.format = "png24";

var entrmap = new esri.layers.ArcGISDynamicMapServiceLayer("http://URL_TO_DYNAMIC/MapServer",
              {"imageParameters":imageParameters}); 

              var visible = [7]; // Only Roads !
              entrmap.setVisibleLayers(visible); //<---------This is how you set it

map.addLayer(entrmap);
3
  • You have multiple ways to on/off the layers , one of them like what i wrote , and also one of them yours ! but still no transparency !
    – Mathboy
    May 27, 2012 at 5:21
  • @Mathboy: esri.layers.ImageParameters is used in the way that you have only when calling ArcGISDynamicMapServiceLayer.exportMapImage, Geoprocessor.getResultImage, and Geoprocessor.getResultImageLayer. If you still do not get a transparent image, something is wrong with your ArcGIS server. Have you tried exporting an image manually from the REST end point? Have you tired consuming the Map service in ArcMap, and switching the layers off and on? May 28, 2012 at 15:04
  • Yes i tried to open the layers via ArcMap , and everything went perfect , so i'm sure there's something should be in the code to activate the transparency
    – Mathboy
    Jun 3, 2012 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.