AnsweredAssumed Answered

LabelLayer class: how to display domain description, not code value?

Question asked by a_morgan on Apr 23, 2015
Latest reply on Apr 23, 2015 by a_morgan

My goal:  Allow users to dynamically add labels.  They would select a field to be labeled along with their preferred font size and color.

 

LabelLayer appears to be the closest solution.  My code below is working without error, however it shows the domain Coded Values instead of the readable Description values.   Is there any workaround to get the description text whenever the field is associated with a domain?

 

Here is an example of converting a domain value's code to description  Using Domain values in your App

But this doesn't help because LabelLayer's ".addFeatureLayer" method doesn't appear to allow anything more than the field name itself.

 

  function addLabelLayer() {

        var labelField = "SOURCE";
        var colorLabel = new Color("#0000FF");
        var labelTextSymbol = new TextSymbol().setColor(colorLabel);
        labelTextSymbol.font.setSize("12pt");
        labelTextSymbol.font.setFamily("arial");
        var labelRenderer = new SimpleRenderer(labelTextSymbol);

        var wlFeatLayer = new FeatureLayer(
            mapServerURL + "/15",
            {
                id: "wlFeatureLayer",
                outFields: ["*"]
            });

        
        wlFeatLayer.on('load', function () {

            var labels = new LabelLayer({ id: "wlLabels" });
            labels.addFeatureLayer(wlFeatLayer, labelRenderer, "${" + labelField + "}");
            app.map.addLayer(labels);
            labels.visible = true;

        });

        app.map.addLayer(wlFeatLayer);

    }

Outcomes