Athanasis77

Print task not showing layer generated with dynamic renderer from a Feature layer using join with a relational table

Discussion created by Athanasis77 on Apr 19, 2018

Dear all,

 

I'm having a major problem to execute the print task in my application. My map contains a feature layer where the features are previously joined with a relational (i.e. postgresql) table. I use the GenerateRendererTask to generate a Natural Breaks renderer with some classes, as described here in the API samples.

The layer is shown fine in the map and when I fire the Print button the print task is executed without any error / warning in the code. However the exported map contains only the basemap layer and the graphics from the feature service are ignored. See Fig 1 and Fig 2 attached. When I use the Print task with the same feature layer but with no use of the GenerateRendererTask, the map is printed correctly.  Furthermore, when I substitute the feature layer with another feature layer  not joined with a relational table the print task is also executed as expected. See Figs. 3 and 4 attached.  Thus, the problem – as far as I can assume- is when I want to use the Print task with the GenerateRendererTask in a feature layer where the features are previously joined with a relational (i.e. postgresql) table. The only necessary modifications I have done between the first  case (i.e unsuccessfull printing with renederer from feature layer joined with relational table) and the second case ((i.e successfull printing with renederer from feature layer without any join with relational table) are:

  1. The app.countiesUrl value. In the first page the value is:

<local ip>/gis/rest/services/printtestjoin/MapServer/0" while in the second page:

<local ip>/gis/rest/services/printtestmerge/MapServer/0

  1. The app.outFields and the app.currentAttribute variables. In the first page their values are:

app.outFields = ["<postgresDB>.<schema>.<table>.<field> "];

app.currentAttribute = "<postgresDB>.<schema>.<table>.<field>";

while in the second page their values are:

app.outFields = ["<field>"];

app.currentAttribute = "<field>";

 

 

 Can you please give me any idea about this issue? Below you can find the code for the first page that leads to the unsuccessfull printing.

Unfortunately links to real the pages cannot be provided because the whole application runs under a local intranet.

 

Thank you in advance.

 

....

        parser.parse();

         app.printUrl = "https://<local_ip>/gis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";

 

        esriConfig.defaults.io.proxyUrl = "/proxy/";

        app.map = new Map("map", {

         center: [24, 39],

          basemap: "osm",

          zoom: 7,

          slider: false

        });

 

 

        app.printer = new Print({

          map: app.map,

          url: "https://<local_ip>/gis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"

        }, dom.byId("printButton"));

        app.printer.startup();

   

        app.countiesUrl = "http://<local_ip>/gis/rest/services/printtestjoin/MapServer/0";

        app.layerDef =  layerdef_string;

        app.outFields = ["<postgresDB>.<schema>.<table>.<field>"];

        app.currentAttribute = "<postgresDB>.<schema>.<table>.<field>";

       

       

      

        app.map.on("load", function() {

          app.wash = new FeatureLayer(app.countiesUrl, {

            "id": "layerid",

          

            "maxAllowableOffset": maxOffset(),

            "mode": FeatureLayer.MODE_SNAPSHOT

            

          });       

          app.wash.setDefinitionExpression(app.layerDef);

 

          app.map.addLayer(app.wash);

 

          // colors for the renderer

          app.defaultFrom = Color.fromHex("#FEEECC");

          app.defaultTo = Color.fromHex("#F57917");

         

 

 

          createRenderer("<postgresDB>.<schema>.<table>.<field>");        

        });      

        app.map.on("zoom-end", updateMaxOffset);

 

        var fieldNames, fieldStore, fieldSelect;

 

        function createRenderer(field) {

          app.sfs = new SimpleFillSymbol(

            SimpleFillSymbol.STYLE_SOLID,

            new SimpleLineSymbol(

              SimpleLineSymbol.STYLE_SOLID,

              new Color([0, 0, 0]),

              0.5

            ),

            null

          );

          var classDef = new ClassBreaksDefinition();

          classDef.classificationField = app.currentAttribute;

          classDef.classificationMethod = "natural-breaks";

          classDef.breakCount = 5;

          classDef.baseSymbol = app.sfs;

 

          var colorRamp = new AlgorithmicColorRamp();

          colorRamp.fromColor = app.defaultFrom;

          colorRamp.toColor = app.defaultTo;

          colorRamp.algorithm = "hsv";

          classDef.colorRamp = colorRamp;

 

          var params = new GenerateRendererParameters();

          params.classificationDefinition = classDef;

           params.where = app.layerDef;

          var generateRenderer = new GenerateRendererTask(app.countiesUrl);

          generateRenderer.execute(params, applyRenderer, errorHandler);

        }

 

        function applyRenderer(renderer) {

          app.wash.setRenderer(renderer);

          app.wash.redraw();

        }

        function updateAttribute(ch) {         

          app.currentAttribute = ch;

          createRenderer(ch);

      

        }

        function updateMaxOffset() {

          var offset = maxOffset();

          app.wash.setMaxAllowableOffset(offset);

        }

 

        function maxOffset() {

          return (app.map.extent.getWidth() / app.map.width);

        }

 

        function errorHandler(err) {

          console.log('Oops, error: ', err);

        }

      });

    </script>

  </head>

 

  <body class="tundra">

    <div data-dojo-type="dijit.layout.BorderContainer"

         data-dojo-props="design:'headline',gutters:false"

         style="width: 100%; height: 100%; margin: 0;">

      <div id="map"

           data-dojo-type="dijit.layout.ContentPane"

           data-dojo-props="region:'center'">

<div id="printButton"></div>

       

      </div>

    </div>

  </body>

</html>

Attachments

Outcomes