Select to view content in your preferred language

Why are my map service layers opaque?

897
7
Jump to solution
08-23-2017 07:05 AM
GregSalvador
New Contributor III

Hi all,

I've recently had to switch from writing code in the javascript 4.4 API to the 3.21 API because of the lack toolbar functionality. This means rewriting my code. When I was working with the 4.4, I could call a Map Service by using MapImageLayer. In 3.21, I use ArcGISDynamicMapServiceLayer. However, in 3.21, my layers are completely opaque. This wasn't a problem in 4.4, as MapImageLayer would show the layer the same way it had been published. How do I get the layers to look the same as when they were published?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Greg,

   You just need to use an imageFormat of png32 when your layers need transparency:

https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer-amd.html#imageformat 

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Emeritus

Greg,

   You just need to use an imageFormat of png32 when your layers need transparency:

https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer-amd.html#imageformat 

GregSalvador
New Contributor III

Thanks Robert! Small problem: My layer is now transparent like it should be, but it is only picking up one sublayer. I had thought my opaque shape was covering all of the other sublayers, but now I see that only the one sublayer is being drawn. Is there a way to get the computer to draw all of the layers without me defining every sublayer in the code?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Greg,

   Can you share the code yo are attempting for the layer? Sounds like you are doing something wrong, as all visible sublayers will be drawn unless otherwise specified in your code.

0 Kudos
GregSalvador
New Contributor III

require([
"esri/map",
"esri/layers/ArcGISDynamicMapServiceLayer",
"dojo/domReady!"
], function (Map, ArcGISDynamicMapServiceLayer) {
var map = new Map("map", {
basemap: "topo",
center: [-98.493629, 29.424122], //centers on san antonio
zoom: 10 //zooms to all of bexar county, must be integer
});
var tempLayer = new ArcGISDynamicMapServiceLayer(url);
tempLayer.setImageFormat("png32");
map.addLayer(tempLayer);
console.log(tempLayer.id);
});

The url I am using in the tempLayer requires a login/password to access, and I can't give that out. Is my code correct otherwise? If it is, then maybe the problem is how the layer is set up on my ArcGIS server? I didn't have this problem in 4.4, so maybe there is a difference in what 4.4 and 3.21 need the ArcGIS server settings to be?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Greg,

   Your code looks fine. The difference currently is that 3.x api respects the visibility settings of layers and their sublayer from the map service. So if a layer is visible by default in the map service then it will be displayed as visible in 3.x and if a grouped layer is set to visible false then none of the sublayers will be shown. I know when 4.4 came out sublayer visibility was not respected (this is a bug).

GregSalvador
New Contributor III

Thank you very much sir, I would have never figured all this out on my own. Is there a resource that shows when ESRI is going to update the 4x API? I've seen the functionality matrix, but it is pretty vauge on when some fixes are expected to happen.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Greg,

   No there will be no list of dates when features will be added or fixed. That would be bad business practice for a software development company.

0 Kudos