dmarquardt

Print task doesn't transfer dynamic layer when set the visible layers

Discussion created by dmarquardt on Aug 28, 2013
Latest reply on Oct 24, 2013 by awojcik
Hello,

I'm having a problem with a print tool.

My application prints tiled and dynamic layers. 

If I include the dynamic layers without using setVisibleLayers, all elements of the map are shown in the print task image (result 1)

If i filter the dynamic layers, using setVisibleLayers, the tiled images are shown in the print task image, but the dynamic layers are not (result 2).

Situation 2 happens when I use a dynamic service from a server in my company.  When I use a dynamic service from arcgisonline, though, I can use setVisibleLayers and everything works perfectly.


Has anyone else had this issue?  I'm thinking that it's a difference in map server settings, or in internet permissions.   I'm working with 10.11 services.    


Here's a simplified version of the script I'm using:

            <script src="http://js.arcgis.com/3.6/" type="text/javascript"></script>
            <script  type="text/javascript">
   var map; var dynLyr0;var dynLyr3;var visible=[];        
   require([
   "dojo/ready", "dojo/on","dojo/_base/connect", "dojo/dom","dijit/registry","dojo/parser","esri/map","esri/arcgis/utils","esri/dijit/Print","esri/tasks/PrintTemplate","esri/config","esri/graphic","esri/symbols/SimpleMarkerSymbol","esri/geometry/screenUtils","dojo/_base/array","dojo/dom-construct","dojo/query","dojo/_base/Color","dijit/form/Button","dijit/Menu","dijit/form/HorizontalSlider","dijit/TitlePane","dijit/layout/ContentPane","dijit/form/CheckBox",
   ], function(ready, on, connect,
   dom, registry, parser, Map,  arcgisUtils, Print, PrintTemplate, esriConfig, graphic, SimpleMarkerSymbol, screenUtils, arrayUtils, domConstruct, query, Color, Buttn, Menu, HorizontalSlider, TitlePane, ContentPane, CheckBox
   ) {
   ready(function() {

    parser.parse();
    esriConfig.defaults.io.proxyUrl = "/proxy";
    var ext = new esri.geometry.Extent({ "xmin": -17529487, "ymin": 1874364, "xmax": -5084316, "ymax": 7500129, "spatialReference": { "wkid": 102100} });
    map = new esri.Map("map", { extent: ext       
    });
   
    var background = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
    //var dynLyrUrl = "http://internal.domain.com/arcgis/rest/services/fccGridServiceTest/MapServer/";  //My Internal map service DIDN'T WORK
    var dynLyrUrl = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/";  // THIS ONE WORKS
    dynLyr0 = new esri.layers.ArcGISDynamicMapServiceLayer(dynLyrUrl, {"id": "Original"}); 
    dynLyr0.setVisibleLayers([3]);
    dynLyr0.setOpacity(.85);
    map.addLayers([background, dynLyr0]);
    createPrintDijit();
   
    function createPrintDijit(){
     var printTemplates = new PrintTemplate();
     printTemplates =[{
      label: "Map",
      format: "PDF",
      layout: "MAP_ONLY",
      showAttribution:false,
      exportOptions: {
        width: map.width,
        height: map.height,
        dpi: 96
     }
     }, {
      label: "Landscape",
      format: "png32",
      layout: "A4 Landscape",
      showAttribution:false
     }];
     // print dijit
     printer = new Print({
      map: map,
      templates: printTemplates,
      url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
     }, dojo.byId("prnt"));
     console.log(map.getLayer("Original"));
     printer.startup();    
    }
    });
    });

    function changeOpacity(op) {       
    var newOp = (op / 100);
    }

    function updateLayerVisibility0() {
    if(foodLyr0.checked){
    dynLyr0.setVisibility(true);
    }
    else{
    dynLyr0.setVisibility(false);

    }
    }

Outcomes