I have a javascript/HTML5 web application that uses a dynamic mapservice and a feature layer. I have been able to apply opacity to the dynamic mapservice on both the map and the print-out using
var imageParameters = new ImageParameters();
imageParameters.format = "png32";
before loading the dynamic mapservice
then during the loading of the dynamic mapservice I apply the imageParameters and opacity for the mapservice
dynaLayer1 = new ArcGISDynamicMapServiceLayer(Mapserver + DynMapservice, {
"id": "mapper",
opacity: 1.0,
"imageParameters": imageParameters
});
map.addLayers([dynaLayer1]);
I tried to apply the same logic for a feature layer, but the symbol is solid in the print-out instead of transparent (thus obscuring the underlying layers).
Thus can you control the opacity of a feature layer for a javascript/HTML5 print-out?
Michael,
For a FeatureLayer, you should be able to specify the opacity right in the constructor; additionally, per the API, there's a setOpacity() method you can call.
FeatureLayer | API Reference | ArcGIS API for JavaScript
So, does this work in the app, just not in the printout? I had an issue with opacity before with a unique value renderer - the API didn't like how I was constructing the renderer... let me see if I can dig that up.
Here's the thread:
UniqueValueRenderer - Transparency issue with SimpleMarkerSymbol
I tried it in the sandbox and it worked for both methods (ArcGIS API for JavaScript Sandbox😞
Here's how it looked without setting opacity:
Chris:
Are you displaying a print-out or just the map on the screen? In my scenario the opacity is being maintained in the map on the screen, but not in the print-out.
The second images with the scalebar in the lower right-hand corner is the printout. You can try it yourself, too, in the sandbox - ArcGIS API for JavaScript Sandbox
I didn't make a jsfiddle since it's only a one-line change in the demo.
Chris:
Thanks for the code samples.
The code I am working on uses a different methodology for adding the feature layer. You add the feature layer at map initialization using MODE_SNAPSHOT, but in the application I'm working with the feature layer gets added to the map dynamically by the user with MODE_ONDEMAND.
Also, you are not assigning a renderer or a selectionSymbol on the feature layer which is done in the web application I am working on.
As such when I applied your code to my scenario, it did not fix the opacity issue with the print-out.
I would look at the renderer/selection symbol, if you haven't already - I posted a thread earlier where I ran into opacity issues... it's possible you may be experiencing a similar scenario. Is it at all possible for you to create a jsfiddle demonstrating the issue?