AnsweredAssumed Answered

Change label field for ArcGISDynamicMapServiceLayer

Question asked by GareySmiley on Aug 4, 2017
Latest reply on Aug 7, 2017 by rscheitlin

Trying to change the field used for a label in a lay with in a ArcGISDynamicMapServiceLayer layer. Here's what I tried.

 

var json = {
"labelPlacement":"esriServerPolygonPlacementAlwaysHorizontal"
,"where":null
,"labelExpression":"[States.NAME]"
,"useCodedValues":true
,"symbol":{
"type":"esriTS"
,"color":[0,0,0,255]
,"backgroundColor":null
,"borderLineColor":null
,"borderLineSize":null
,"verticalAlignment":"bottom"
,"horizontalAlignment":"left"
,"rightToLeft":false
,"angle":0
,"xoffset":0
,"yoffset":0
,"kerning":true
,"haloColor":null
,"haloSize":null
,"font":{
"family":"Arial"
,"size": 8
,"style":"normal"
,"weight":"normal"
,"decoration":"none"
}
}
,"minScale":0
,"maxScale":0
};

// create instance of LabelClass
var labelClass = new LabelClass(json);
console.log("labelClass",labelClass);

var layerDrawingOptions = [];
var layerDrawingOption = new esri.layers.LayerDrawingOptions();

var renderer = response.renderer;

layerDrawingOption.renderer = renderer;

layerDrawingOption.showLabels = true;
layerDrawingOption.labelingInfo = labelClass;

// Sets the opacity (transparency) of the layer.
// Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.
layerDrawingOption.transparency = transparency;

console.log("layerDrawingOption",layerDrawingOption);

layerDrawingOptions[1] = layerDrawingOption;
geoLayer.setLayerDrawingOptions(layerDrawingOptions);

 

Any ideas would be appreciated. 

Outcomes