# Getting polylines to lie flat.

**URL:** <https://community.cesium.com/t/getting-polylines-to-lie-flat/2845>\
**Category:** CesiumJS\
**Created:** [July 26, 2015, 6:33pm UTC](https://community.cesium.com/t/getting-polylines-to-lie-flat/2845 "2015-07-26T18:33:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerrold\_Siegel](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/jerrold_siegel/32/3077_2.png) [@Jerrold\_Siegel](https://community.cesium.com/u/Jerrold_Siegel)\
**Post date:** [July 26, 2015, 6:33pm UTC](https://community.cesium.com/t/getting-polylines-to-lie-flat/2845/1 "2015-07-26T18:33:01Z")

</div>

I have been trying to have a collection of polylines lie flat on a terrain but get almost vertical renderings.  
poly2.jpg is what I am seeing, poly0.jpg are typical endpoints of a polyline, and what I think is the relevant code is:

**this\_viewer.entities.add({**

```auto
 ** polyline :{
                            positions : this_Cesium.Cartesian3.fromDegreesArrayHeights(
                              [block_edgepoints_llh[i][0], block_edgepoints_llh[i][1], block_edgepoints_llh[i][2],
                              block_edgepoints_llh[i+1][0], block_edgepoints_llh[i+1][1], block_edgepoints_llh[i+1][2]
                              ]),
                           width : 40,
                           followSurface : true,
                           material : this_Cesium.Color.GREEN
                           }
                            });**

```

```auto

```

```auto
I tried various things such as **followSurface: false** but to no avail. I checked the documentation but could see nothing there as well. Is there a control I am missing?

```

```auto

```

![poly2.jpg](https://global.discourse-cdn.com/cesium/original/1X/8fb855da62c07d9d1c44df1d7355129dc4818859.jpeg)

![poly0.jpg](https://global.discourse-cdn.com/cesium/original/1X/ce710f7761993a7cba1accdf7db53a4c9caf074d.jpeg)

---

<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:** [July 27, 2015, 1:57pm UTC](https://community.cesium.com/t/getting-polylines-to-lie-flat/2845/2 "2015-07-27T13:57:26Z")

</div>

Hello Jerry,

Your code looks like it should work. Do you have more sample data I could test with?

Thanks,

Hannah

---

<div class="post-metadata">

**Author:** ![Jerrold\_Siegel](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/jerrold_siegel/32/3077_2.png) [@Jerrold\_Siegel](https://community.cesium.com/u/Jerrold_Siegel)\
**Post date:** [July 27, 2015, 3:22pm UTC](https://community.cesium.com/t/getting-polylines-to-lie-flat/2845/3 "2015-07-27T15:22:19Z")

</div>

Hi Hannah,

Thanks. I stripped my code down to[http://vcities.ite-stl.org/Cesium/Apps/Sandcastle/gallery/polylinetest.html](http://vcities.ite-stl.org/Cesium/Apps/Sandcastle/gallery/polylinetest.html) . When you open it you see the block I am working with. **Fix Corner Heights** runs the relevant code. I realized after the fact that the button is misnamed but I just left it.

I had moved all my terrain height fix code to blockmath.js I just left it there but attached both files.

Jerry

[blockmath.js](https://community.cesium.com/uploads/short-url/rdj03JEiUEAdVWi54ZNdqcu4hmb.js) (7.46 KB)

[polylinetest.html](https://community.cesium.com/uploads/short-url/e4rVUBdUbHldUoyOdlDYL7iTyih.html) (5.72 KB)

---

<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:** [July 27, 2015, 5:27pm UTC](https://community.cesium.com/t/getting-polylines-to-lie-flat/2845/4 "2015-07-27T17:27:45Z")

</div>

Thanks Jerry. Unfortunately, I don’t think you can use polylines to accomplish what you want to do. They’re drawn such that they have the same pixel width on the screen regardless of the camera distance. They are appearing jagged because parts of the line are getting rendered under the terrain from certain camera angles.

We are working on getting a polygons on terrain feature in. You can see the progress here: [https://github.com/AnalyticalGraphicsInc/cesium/pull/2865](https://github.com/AnalyticalGraphicsInc/cesium/pull/2865)

Dan is making really good progress and it should be ready soon.

In the mean time, you could try using the perPositionHeight option on your polygon. You could specify a height for each position along the perimeter.

Here is an example:

var orangePolygon = viewer.entities.add({

name : ‘Orange polygon with per-position heights and outline’,

polygon : {

hierarchy : Cesium.Cartesian3.fromDegreesArrayHeights([-108.0, 25.0, 100000,

-100.0, 25.0, 100000,

-100.0, 30.0, 100000,

-108.0, 30.0, 300000]),

perPositionHeight : true,

material : Cesium.Color.ORANGE.withAlpha(0.5),

outline : true,

outlineColor : Cesium.Color.BLACK

}

});

``

-Hannah

---

<div class="post-metadata">

**Author:** ![Jerrold\_Siegel](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/jerrold_siegel/32/3077_2.png) [@Jerrold\_Siegel](https://community.cesium.com/u/Jerrold_Siegel)\
**Post date:** [July 27, 2015, 6:34pm UTC](https://community.cesium.com/t/getting-polylines-to-lie-flat/2845/5 "2015-07-27T18:34:42Z")

</div>

Hannah,  
In fact, that is exactly what I was looking for.

Much thanks, yet again.

Jerry

---

<div class="post-metadata">

**Author:** ![Jerrold\_Siegel](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/jerrold_siegel/32/3077_2.png) [@Jerrold\_Siegel](https://community.cesium.com/u/Jerrold_Siegel)\
**Post date:** [July 31, 2015, 1:28pm UTC](https://community.cesium.com/t/getting-polylines-to-lie-flat/2845/6 "2015-07-31T13:28:46Z")

</div>

Hannah,  
I wanted to thank you again and show you where I am, which is where I want to be. I picked a block with very few building.

Jerry

 ![block_with_alley.jpg](https://global.discourse-cdn.com/cesium/original/2X/6/68d5fbf8bb8adef1c2389a6bb39b2431ed972ab5.jpeg)

---

<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:** [July 31, 2015, 4:03pm UTC](https://community.cesium.com/t/getting-polylines-to-lie-flat/2845/7 "2015-07-31T16:03:34Z")

</div>

Looks great! I’m glad that worked out for you.  
Your project is really interesting, I can’t wait to see it when it’s finished.

-Hannah
