# fromDegrees not mapping the same as my KML

**URL:** <https://community.cesium.com/t/fromdegrees-not-mapping-the-same-as-my-kml/4258>\
**Category:** CesiumJS\
**Created:** [June 20, 2016, 4:13pm UTC](https://community.cesium.com/t/fromdegrees-not-mapping-the-same-as-my-kml/4258 "2016-06-20T16:13:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shane\_Thomas](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Shane\_Thomas](https://community.cesium.com/u/Shane_Thomas)\
**Post date:** [June 20, 2016, 4:13pm UTC](https://community.cesium.com/t/fromdegrees-not-mapping-the-same-as-my-kml/4258/1 "2016-06-20T16:13:39Z")

</div>

I am trying to get an entity (or a SingleTileImageryProvider anyone i can get to work) to map my image to a globe. I have a kml file that maps/looks right (no imagery stuff just a box).

\<?xml version="1.0" encoding="UTF-8"?\>  
\<kml xmlns="[http://www.opengis.net/kml/2.2](http://www.opengis.net/kml/2.2)"\>  
&nbsp;&nbsp;\<Placemark\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<name\>Maui\</name\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<visibility\>1\</visibility\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<styleUrl\>#transBluePoly\</styleUrl\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<Polygon\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<tessellate\>1\</tessellate\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<altitudeMode\>absolute\</altitudeMode\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<outerBoundaryIs\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<LinearRing\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<coordinates\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-156.6225,20.5594444444444,1000  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-156.676388888889,20.8205555555556,1000  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-156.205833333333,20.9055555555556,1000  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-156.1525,20.6447222222222,1000  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</coordinates\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</LinearRing\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</outerBoundaryIs\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</Polygon\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</Placemark\>  
\</kml\>

So I have tried this code in the entities to map a rectangle:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var redRectangle = viewer.entities.add({  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name : 'Red translucent rectangle with outline',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rectangle : {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;coordinates : Cesium.Rectangle.fromDegrees(-156.6225,20.5594444444444,-156.1525,20.6447222222222),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;material : Cesium.Color.RED.withAlpha(0.5),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outline : true,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outlineColor : Cesium.Color.RED

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

I am not sure where my disconnect is but this is not even coming close to the foot print in the KML file. Not sure what I am doing wrong but getting these to match up would be awesome. Then I could ignore the fact that cesium doesn't handle tiled imagery in my kmz and just map the one image 1:1 onto the globe as a stop gap measure until further support for regions exists in Cesium.

---

<div class="post-metadata">

**Author:** ![Shane\_Thomas](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Shane\_Thomas](https://community.cesium.com/u/Shane_Thomas)\
**Post date:** [June 20, 2016, 4:20pm UTC](https://community.cesium.com/t/fromdegrees-not-mapping-the-same-as-my-kml/4258/2 "2016-06-20T16:20:07Z")

</div>

Just a graphic to show what I am seeing:  
[![](https://ibin.co/2lKWuQJJagsR.png) ](https://ibin.co/2lKWuQJJagsR.png)

---

<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:** [June 20, 2016, 5:19pm UTC](https://community.cesium.com/t/fromdegrees-not-mapping-the-same-as-my-kml/4258/3 "2016-06-20T17:19:27Z")

</div>

Hello,

Instead of using a rectangle, try using a polygon with those four coordinates:

viewer.entities.add({  
polygon : {  
hierarchy : Cesium.Cartesian3.fromDegreesArray([-156.6225,20.5594444444444,  
-156.676388888889,20.8205555555556,  
-156.205833333333,20.9055555555556,  
-156.1525,20.6447222222222]),  
material : Cesium.Color.RED  
}  
});

``

The rectangle is meant to follow the longitude and latitude lines, which is why it doesn’t line up.

Best,

Hannah

---

<div class="post-metadata">

**Author:** ![Shane\_Thomas](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Shane\_Thomas](https://community.cesium.com/u/Shane_Thomas)\
**Post date:** [June 20, 2016, 5:41pm UTC](https://community.cesium.com/t/fromdegrees-not-mapping-the-same-as-my-kml/4258/4 "2016-06-20T17:41:40Z")

</div>

indeed that worked! Though using my image as a material still doesn't line up (I am guessing it is a scaling/zoom level issue). I might have to throw in the towel on hacking a work around to get images tiled onto the virtual globe for now . I just cannot seem to find a way that makes this work. On a whim I tried this even:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;layers.addImageryProvider(new Cesium.SingleTileImageryProvider({  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;url : 'Sandcastle/images/test.png',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;polygon : Cesium.Cartesian3.fromDegreesArray([-156.6225,20.5594444444444,  
&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;-156.676388888889,20.8205555555556,  
&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;-156.205833333333,20.9055555555556,  
&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;-156.1525,20.6447222222222])  
&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;});

Maps the test.png to the entire globe, I am guessing SingleTileImageryProvider does not like a rectangle property.

---

<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:** [June 20, 2016, 7:42pm UTC](https://community.cesium.com/t/fromdegrees-not-mapping-the-same-as-my-kml/4258/5 "2016-06-20T19:42:13Z")

</div>

Oh okay, I understand what you’re trying to do now. We don’t currently have support for KML lat lon quads and projecting the image to rectangles like this.  
It’s part of our KML roadmap: [https://github.com/AnalyticalGraphicsInc/cesium/issues/2179](https://github.com/AnalyticalGraphicsInc/cesium/issues/2179)

I’m not sure how long it will be before we have a chance to address this though.

You can take a look at this issue to see how they worked around adding an image: [https://groups.google.com/d/msg/cesium-dev/x3sYLgIr8Mc/t4tSUBh3CQAJ](https://groups.google.com/d/msg/cesium-dev/x3sYLgIr8Mc/t4tSUBh3CQAJ)

-Hannah
