Custom labeling annotation on web map

2980
0
02-01-2016 10:13 AM
JieCai
by
New Contributor

I have a problem to display the calculated property value in javascript api label object. If anybody knows how to solve this issue, could you share your idea? Thanks!

Here is code:

// create a renderer for the FNP layer to override default symbology

            var FNPColor = new Color("#666");

            var FNPColor = new Color("#FF0000");

            var FNPLine = new SimpleLineSymbol("solid", FNPColor, 1.5);

            var FNPSymbol = new SimpleFillSymbol("solid", FNPLine, null);

            var FNPRenderer = new SimpleRenderer(FNPSymbol);

var FNPlayer = new FeatureLayer("https://oursite/webgis/rest/services/Cooperators/cooperatorboundaryandpond/FeatureServer/1", {

                mode: FeatureLayer.MODE_SELECTION,

                outFields: ["*"],

       

            });

// create a text symbol to define the style of labels

            var FNPLabel = new TextSymbol().setColor(FNPColor);

            FNPLabel.font.setSize("8pt");

            FNPLabel.font.setFamily("arial");

            var json = {

                "labelExpressionInfo": [{ "value": "{Name}" },{"Value"}:calculateAcreageFNP}] // Here is the value need be displayed in the label

                "labelPlacement": "above-right"

            };

            var labelClass = new LabelClass(json);

            labelClass.symbol = FNPLabel; // symbol also can be set in LabelClass' json

            FNPlayer.setLabelingInfo([labelClass]);

function calculateAcreageFNP(value) {

       

                var sqft = geometryEngine.geodesicArea(value.geometry, "square-feet");

                console.log(sqft);

                var squarefeet = number.format(sqft, { places: 1 });

                var acres = number.format(sqft / 43560, { places: 2 });

                return "Acres :" + acres ;

            };

0 Kudos
0 Replies