Add the textSymbol to the center of polyLine

12-19-2014 01:43 AM
New Contributor


I would like to print a textSymbol on center of the ployLine using the Longitude and Latitude.

I Have written the below code, but Unable to print the textSymbol.

var labelGraphic = null;

var startX = lLong[0];// These are string values

var endX = lLong[lLong.length-1];

var startY= lLat[0];

var endY = lLat[lLat.length-1];

var midPointX = ((endX - startX) / 2);

var midPointY = ((endY - startY) / 2);

var font = new Font("12px", Font.STYLE_NORMAL, Font.STYLE_NULL, Font.VARIANT_NORMAL, Font.WEIGHT_NULL, "Arial");  

var pipePoint = new Point(((parseFloat(lLong[0]))+midPointX ) , ((parseFloat(lLat[0]))+ midPointY), map.spatialReference);

// create a text symbol 

var textSymbol = new TextSymbol("LABEL TEXT!!!", font, new Color([0, 0, 0])); 

labelGraphic = new Graphic(pipePoint, textSymbol);

if (labelGraphic != null);

Please help me how to add the textSymbol to the polyline.

0 Kudos
10 Replies
Esri Contributor

A polyline doesn't have an angle, only a straight line does. But a polyline is made up of smaller straight line segments. Find the segment where you want to place the symbol and calculate it's angle.

0 Kudos