Override item names in legend print task

2765
9
Jump to solution
04-19-2018 09:12 AM
Juan_ManuelAngel_Cuartas
New Contributor II

Hi!

I added some graphics in a graphicLayer which works well in the browser web map and also in the PNGproduced with the server print task. You can see the graphics in the PNG but in the legend you see the symbols but only the item names "Override 1" "Override 2" etc. I'm unable to change Override items.

I know that is related to label field of renderer in the layer, beacuse I make a test changing manually de JSON in a JSON editor, but I don't know how to create the object in the API to send the right JSON and be able to change de Override.

 

I've tried with a FeatureCollection and add a renderer with label,but doesn't work either. 

function showFullPolygon(resultPolygon) {

console.log(resultPolygon);

/** Ocultar loading del SIT */
SIT.HideLoading();

/** Simbología para dibujar los colindantes*/
var symbol = new SimpleFillSymbol(
SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color([77, 89, 93]), 2
),
new Color([208, 141, 0, 0.19])
);

/** Definir las capas resultantes del geoproceso fuentes externas*/
featuresCrossPoly = resultPolygon.value.features;

var defaultSymbol = new SimpleFillSymbol().setStyle(SimpleFillSymbol.STYLE_NULL);
defaultSymbol.outline.setStyle(SimpleLineSymbol.STYLE_NULL);
var renderer = new UniqueValueRenderer(defaultSymbol, "CAPA");

var GLayer = new GraphicsLayer();
GLayer.id = "cruce";

/*
* Recorrer cada capa que sera
* dibujada como un gráfico en el mapa
*/
for (var i = 0, il = featuresCrossPoly.length; i < il; i++) {

leyendaCapas.forEach(function (capas) {
if (featuresCrossPoly.attributes.CAPA == capas.name) {
var symbol = new SimpleFillSymbol(
SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color([capas.rgb]), 2
),
new Color([115, 178, 115, 0.35])
);
}
});

var textLegend = featuresCrossPoly.attributes.CAPA;

/** Capa gráfica para colindantes*/
var graphic = featuresCrossPoly;

//graphic.geometry.spatialReference = map.spatialReference;
graphic.geometry = webMercatorUtils.geographicToWebMercator(graphic.geometry);

var legendGraphic = featuresCrossPoly.geometry.getExtent().getCenter();

var legend = new esri.symbol.TextSymbol();

//legend.setColor([132, 134, 76]);
legend.setText(textLegend);

legend.setAlign(esri.symbol.TextSymbol.ALIGN_MIDDLE);

legend.setHorizontalAlignment("center");

/** Asignar simbología */
graphic.setSymbol(symbol);

/** Obtener extent y centro para leyenda */
//map.graphics.add(graphic);
//GLayer.add(graphic);
map.graphics.add(graphic);
map.graphics.add(new esri.Graphic(legendGraphic, legend));
console.log(graphic);

}

GLayer.renderer = renderer;
featuresCrossPoly.renderer = renderer;
map.addLayer(GLayer);
console.log(graphic);
//map.addLayer(featuresCrossPoly);
queryExternalCross();
}

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
SangHyouk_Oum
New Contributor III

Can you check if this is also fine on JSAPI 4.7? I am working on upgrading from JSAPI 4.5 to 4.7. It works fine on JSAPI 4.5 (Legend label printed as "SWITRS Collision") but it does not work on JSAPI 4.7 (Legend label printed as "Override 1").

When I compared Web_Map_as_JSON on these two, I found that JSAPI 4.7 does not include "drawingInfo" in layerDefinition. Please see the JSON code below.

A. from JSAPI 4.5:

{
   "operationalLayers":[
     {
         "id":"colLayer",
         "title":"SWITRS Collisions",
         "opacity":1,
         "minScale":0,
         "maxScale":0,
         "url":null,
         "token":null,
         "featureCollection":{
            "layers":[
               {
                  "layerDefinition":{
                     "name":"SWITRS Collisions",
                     "geometryType":"esriGeometryPoint",
                     "drawingInfo":{
                        "renderer":{
                           "type":"uniqueValue",
                           "field1":"selected",
                           "defaultLabel":"Collisions",
                           "defaultSymbol":{
                              "type":"esriSMS",
                              "color":[
                                 59,
                                 126,
                                 161,
                                 179
                              ],
                              "angle":0,
                              "xoffset":0,
                              "yoffset":0,
                              "size":10,
                              "style":"esriSMSCircle",
                              "outline":{
                                 "type":"esriSLS",
                                 "color":[
                                    255,
                                    255,
                                    255,
                                    255
                                 ],
                                 "width":0.5,
                                 "style":"esriSLSSolid"
                              }
                           },
                           "uniqueValueInfos":[
                              {
                                 "value":"1",
                                 "symbol":{
                                    "type":"esriSMS",
                                    "color":[
                                       59,
                                       126,
                                       161,
                                       179
                                    ],
                                    "angle":0,
                                    "xoffset":0,
                                    "yoffset":0,
                                    "size":12,
                                    "style":"esriSMSCircle",
                                    "outline":{
                                       "type":"esriSLS",
                                       "color":[
                                          217,
                                          102,
                                          31,
                                          255
                                       ],
                                       "width":1.5,
                                       "style":"esriSLSSolid"
                                    }
                                 },
                                 "label":"Collisions - Selected"
                              }
                           ]
                        }
                     },
                     "fields":[
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

B. from JSAPI 4.7:

{
   "operationalLayers":[
      {
         "id":"colLayer",
         "title":"SWITRS Collisions",
         "opacity":1,
         "minScale":0,
         "maxScale":0,
         "url":null,
         "token":null,
         "featureCollection":{
            "layers":[
               {
                  "layerDefinition":{
                     "name":"SWITRS Collisions",
                     "geometryType":"esriGeometryPoint",
                     "fields":[‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

9 Replies
RobertScheitlin__GISP
MVP Emeritus

Juan,

   Have you seen the release note on 3.24?

  • BUG-000086442/BUG-000094164: Fixed issue with printing layers that do not use default symbology, and instead print "Override" in the legend, using 10.6+ print services.
0 Kudos
BjornSvensson
Esri Regular Contributor

Juan Manuel Angel Cuartas‌ - what versions of API are you using? And what version of the print server?  

We made some fixes for this, but it requires
(a) a Pro-based print service 10.6 or later 
(b) JSAPI 4.5 (December) or later, or JSAPI 3.24 (April)

With the ArcGIS Online release week, you can test on www.arcgis.com.

0 Kudos
SangHyouk_Oum
New Contributor III

Can you check if this is also fine on JSAPI 4.7? I am working on upgrading from JSAPI 4.5 to 4.7. It works fine on JSAPI 4.5 (Legend label printed as "SWITRS Collision") but it does not work on JSAPI 4.7 (Legend label printed as "Override 1").

When I compared Web_Map_as_JSON on these two, I found that JSAPI 4.7 does not include "drawingInfo" in layerDefinition. Please see the JSON code below.

A. from JSAPI 4.5:

{
   "operationalLayers":[
     {
         "id":"colLayer",
         "title":"SWITRS Collisions",
         "opacity":1,
         "minScale":0,
         "maxScale":0,
         "url":null,
         "token":null,
         "featureCollection":{
            "layers":[
               {
                  "layerDefinition":{
                     "name":"SWITRS Collisions",
                     "geometryType":"esriGeometryPoint",
                     "drawingInfo":{
                        "renderer":{
                           "type":"uniqueValue",
                           "field1":"selected",
                           "defaultLabel":"Collisions",
                           "defaultSymbol":{
                              "type":"esriSMS",
                              "color":[
                                 59,
                                 126,
                                 161,
                                 179
                              ],
                              "angle":0,
                              "xoffset":0,
                              "yoffset":0,
                              "size":10,
                              "style":"esriSMSCircle",
                              "outline":{
                                 "type":"esriSLS",
                                 "color":[
                                    255,
                                    255,
                                    255,
                                    255
                                 ],
                                 "width":0.5,
                                 "style":"esriSLSSolid"
                              }
                           },
                           "uniqueValueInfos":[
                              {
                                 "value":"1",
                                 "symbol":{
                                    "type":"esriSMS",
                                    "color":[
                                       59,
                                       126,
                                       161,
                                       179
                                    ],
                                    "angle":0,
                                    "xoffset":0,
                                    "yoffset":0,
                                    "size":12,
                                    "style":"esriSMSCircle",
                                    "outline":{
                                       "type":"esriSLS",
                                       "color":[
                                          217,
                                          102,
                                          31,
                                          255
                                       ],
                                       "width":1.5,
                                       "style":"esriSLSSolid"
                                    }
                                 },
                                 "label":"Collisions - Selected"
                              }
                           ]
                        }
                     },
                     "fields":[
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

B. from JSAPI 4.7:

{
   "operationalLayers":[
      {
         "id":"colLayer",
         "title":"SWITRS Collisions",
         "opacity":1,
         "minScale":0,
         "maxScale":0,
         "url":null,
         "token":null,
         "featureCollection":{
            "layers":[
               {
                  "layerDefinition":{
                     "name":"SWITRS Collisions",
                     "geometryType":"esriGeometryPoint",
                     "fields":[‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Noah-Sager
Esri Regular Contributor

I just tested with 4.7, and a Pro-based print service (10.6.0 or later), and I can see the proper titles for features in the print-out legend. I also do not see `drawingInfo` in the WebMapAsJSON.

What version is your Print Server?

Here are some public facing ones that you can use for testing:

"https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%..."

Task: Export Web Map Task 

-Noah

SangHyouk_Oum
New Contributor III

Thank you for testing, Noah. 

I also did used:

https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%...

Can you share your code if it's possible? I would like to compare why it's not showing on my end. I was able to see the name from the featureLayer hosted online but not for the featurelayer generated in the client using feature collections. Below is how I made. It shows "Collisions" in the legend in JSAPI4.5 but shows "Override 1" in JSAPI4.7.

      renderer = new UniqueValueRenderer({
        field: "selected",
        defaultSymbol: new SimpleMarkerSymbol({
          size: size,
          color: rgba,
          outline: {
            width: 0.5,
            color: "white"
          }
        }),
        defaultLabel: "Collisions"
      });


          var option = {
            id: "colLayer",
            layerId: "colLayer",
            title: "SWITRS Collisions",
            fields: fset.fields,
            source: fset.features,
            objectIdField: "CASEID",
            geometryType: "point",
            spatialReference: fset.spatialReference,
            renderer: renderer,
            popupTemplate: {
              title: "CASEID: {CASEID}",
              content: popupContent,
              actions: [{
                title: "Collision Details",
                id: "detailLink",
                className: "esri-icon-browser"
              }],
              fieldInfos: [{
                fieldName: "DATE_",
                format: {
                  dateFormat: "long-month-day-year"
                }
              }]
            }
          };
          var colLayer = new FeatureLayer(option);
0 Kudos
Noah-Sager
Esri Regular Contributor

I was able to see the name from the featureLayer hosted online but not for the featurelayer generated in the client using feature collections.

I see now. I am experiencing the same behavior. Thank you for bringing this up. We will investigate.

-Noah

SangHyouk_Oum
New Contributor III

Hi Noah, 

Have you had a chance to look at this? We want to release our site using JS API 4.7 but we cannot because of this issue. Or, maybe any way to workaround?

0 Kudos
Noah-Sager
Esri Regular Contributor

Unfortunately, I don't have a solution to share at this time. We are investigating the issue to be addressed at a later release. One option would be to not show those features in the Legend.

-Noah

0 Kudos
Juan_ManuelAngel_Cuartas
New Contributor II

Thank you for all your answers, i solve with python snnipet adding the legend to the mxd but i will try that code with 4.7 and i need to migrate all the code 3.24 to 4.5, thank you so much

0 Kudos