AnsweredAssumed Answered

Override item names in legend print task

Question asked by juanma93_6 on Apr 19, 2018
Latest reply on Jun 11, 2018 by NSager-esristaff

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[i].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[i].attributes.CAPA;

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

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

var legendGraphic = featuresCrossPoly[i].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();
}

Attachments

Outcomes