Changing label expression with ArcGIS JavaScript API?

598
1
10-30-2017 10:12 AM
GUANGRANDENG
New Contributor

I labeled an attribute of a point featureclass in the arcma. And I used the advanced python expression to process this attribute. Then I published my map on the ArcGIS Server. I wanna use the published map to build my web application with arcgis javascript api calling different featureclasses at the front end. Is there any method if I wanna change the advanced python expression using javascript api at the front end? For example, now my label of this featureclass is the temperature expression, and I wanna change it to rainfall expression at the front end (map is already published). All the attributes are in the same attribute table. It seems like it can not change any style of the map once I publish the map on the server. Thank you.

0 Kudos
1 Reply
ColleenDixon
New Contributor

I have the exact same question, per some documentation I tried the following to no avail, where labelInfo.LabelExpression is "[creationUser]"  Can anyone offer some insight?

public updateLabelingInfo(layerId: number, labelInfo: LabelInfo) {
    const options = this.dynamicLayer.layerDrawingOptions;
    const labelClass = new LabelClass();
    labelClass.labelExpressionInfo = { value: labelInfo.LabelExpression };
    options[layerId].labelingInfo = [labelClass];
    this.dynamicLayer.setLayerDrawingOptions(options);
}
0 Kudos