killion92

Drawing line with polyline.addPath

Discussion created by killion92 on Jul 23, 2010
Latest reply on Jul 26, 2010 by killion92
Hello,
I'm trying to draw a line on the map using the addPath method. Here's the code snippet (using v1.6):
var line = new esri.geometry.Polyline(new esri.SpatialReference( {wkid:102100} ));
var path = new Array();
   
for (i=0; i<xPoints.length; i++)
{
    coords = '[' + xPoints[i] + ',' + yPoints[i] + ']';
    path.push(coords);
}
   
alert(path);
   
line.addPath(path);

alert(line.paths);


The first alert shows the path formatted like this:
[-10993319,4632566],[-10907471,4612961]
which seems correct to me.

However, the second alert (after the path is added to the polyline) only shows 3 commas (,,,) so the path doesn't get added and the line doesn't draw.

Any ideas appreciated.
Mike

Outcomes