bryce.hemme

Print FeatureLayer labels in 3.5 and earlier

Discussion created by bryce.hemme on Oct 19, 2013
Latest reply on Oct 20, 2013 by bryce.hemme
I have a need to implement labels on features in a FeatureLayer in version 3.5. The labels are from a field returned by the REST feature service. I can't move to 3.7 for various reasons at this time. I have tried using a TextSymbol but my map features just turn to the color of the TextSymbol and no text appears. I may be approaching this in he wrong manner, though. Below is the code I'm attempting to use for labeling with the featureLayer object being my instance of the FeatureLayer I'm adding to the map. Is there a different or proper way to accomplish this task?


featureLayer.on("graphic-add", function (evt) {               
                var labelColor = new Color([255, 0, 0, 0.25]);
                var myLabel = new TextSymbol(evt.graphic.attributes["My Field Name"]);

                myLabel.setColor(labelColor);
                myLabel.font.setSize("14pt");

                evt.graphic.setSymbol(myLabel);

                //console.log(evt);


});


Thanks for any help that can be provided!

Outcomes