AnsweredAssumed Answered

Label Polygon Vertices

Question asked by jamesfreddyc on Apr 20, 2018
Latest reply on Apr 23, 2018 by jamesfreddyc

Can anyone point me to an example/sample of labeling polygon geometry at each vertex?


I have a requirement to label each vertex with coordinate info.


Javascript 3.x


Update: I've attempted to implement the Points for Labeling method on the Geometry service, as seen in this example but I'm getting an error


init.js:114 TypeError: Cannot read property '0' of undefined
    at Object.labelPoints (init.js:2548)

getLabelPoints: function (geom) {
            var geometryService = new GeometryService("");
            var geographicGeometries = [];

            if (geom.rings.length > 0) {
                geometryService.labelPoints(this.geom, function(labelPoints) {
                    var font = new Font("20px", Font.STYLE_NORMAL, Font.VARIANT_NORMAL, Font.WEIGHT_BOLDER);
                    array.forEach(this.labelPoints, function (labelPoint) {
                        // create a text symbol
                        var textSymbol = new TextSymbol(
                          "X: " + number.format(labelPoint.x) + ", Y: " + number.format(this.labelPoint.y),
                          font, new Color([0, 0, 0]));

                        var labelPointGraphic = new Graphic(this.labelPoint, textSymbol);

                        // add the label point graphic to the map