# draw polyline within from loop

**URL:** <https://community.cesium.com/t/draw-polyline-within-from-loop/3800>\
**Category:** CesiumJS\
**Created:** [March 3, 2016, 1:06pm UTC](https://community.cesium.com/t/draw-polyline-within-from-loop/3800 "2016-03-03T13:06:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbunic151](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@mbunic151](https://community.cesium.com/u/mbunic151)\
**Post date:** [March 3, 2016, 1:06pm UTC](https://community.cesium.com/t/draw-polyline-within-from-loop/3800/1 "2016-03-03T13:06:23Z")

</div>

In success part of jsonp i recieve lots of polyline. Precisely x,y coordinates of them i want to draw polylines using those cordinates. How should it be done? My part of code is this:

success: function(data){  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;for (var i=0; i \< data.length; i++){  
&nbsp;&nbsp;&nbsp;&nbsp;for (var l=0; l\<data[i].POINTS.length; l++){  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var entity = new Cesium.Polyline();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.position = Cesium.Cartesian3.fromDegrees(data[i].POINTS[l].p\_x, data.POINTS[i].p\_y);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.label = new Cesium.LabelGraphics();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.label.verticalOrigin = Cesium.VerticalOrigin.TOP;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;viewer.entities.add(entity);  
&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;}

}

I don't know how to produce position using x,y coordinate within for loop.

Help please! Thank you in front!

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [March 3, 2016, 4:40pm UTC](https://community.cesium.com/t/draw-polyline-within-from-loop/3800/2 "2016-03-03T16:40:01Z")

</div>

Hello,

Take a look at our polyline example: [http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Polyline.html&label=Geometries](http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Polyline.html&label=Geometries)

You can put your coordinate points in an array ([x1, y1, x2, y2, x3, y3, …]) and pass that array to the Cesium.Cartesian3.fromDegreesArray function

Best,

Hannah
