Extremely simple CZML example

3,776 views
Skip to first unread message

linde...@gmail.com

unread,
Jun 6, 2013, 1:57:09 PM6/6/13
to cesiu...@googlegroups.com
Does anyone have an examples for how to get data from an extremely simple CZML loaded onto a CesiumWidget (preferably not the viewer). I'm basically just trying to draw some polygons on the map. Nothing would change based on time. For example, here's the CZML I'd like to render:

[
{
"id": "MyTestData",
"polygon": {
"material": {
"solidColor": {
"color": {
"rgba": [
255,
165,
0,
255
]
}
}
}
},
"vertexPositions": {
"cartographicDegrees": [
-80.3982608081762,
40.7897431538943,
0,
-50.3906446069755,
40.7897431538943,
0,
-80.3906446069755,
10.7821269526935,
0,
-80.3982608081762,
20.7821269526935,
0,
-60.3982608081762,
30.7897431538943,
0
]
}
}
]

Scott Hunter

unread,
Jun 6, 2013, 1:58:55 PM6/6/13
to cesiu...@googlegroups.com
Take a look at the "Client CZML" Sandcastle example:


I was able to paste your CZML into the editor as the value of var czml and run it with F8.



--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



linde...@gmail.com

unread,
Jun 6, 2013, 2:07:35 PM6/6/13
to cesiu...@googlegroups.com
Thanks. Is there any way I can do with without the viewer though?

Matthew Amato

unread,
Jun 6, 2013, 2:12:24 PM6/6/13
to cesiu...@googlegroups.com
The easiest way for you would probably be the new DataSource abstraction.  I'll post some code in a few minutes.

Matthew Amato

unread,
Jun 6, 2013, 2:28:47 PM6/6/13
to cesiu...@googlegroups.com
Here is a complete example which shows your CZML.  If you copy and paste this as a replacement to HelloWorld.html, you should be good to go.  You'll probably have to tweak the paths to Cesium.js and CesiumWidget.css depending on if you are using a release or git version of Cesium.  Let me know if you have problems getting this running.

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Hello World!</title>
    <script type="text/javascript" src="../Build/Cesium/Cesium.js"></script>
    <style>
      @import url(../Build/Cesium/Widgets/CesiumWidget/CesiumWidget.css);
      body {
        padding: 0;
        margin: 0;
        overflow: hidden;
      }
    </style>
  </head>
<body>
  <div id="cesiumContainer"></div>
  <script>
    var cesiumWidget = new Cesium.CesiumWidget('cesiumContainer');

    var czml = [
            ];
    
    var czmlSource = new Cesium.CzmlDataSource();
    czmlSource.load(czml);

    var dataSourceDisplay = new Cesium.DataSourceDisplay(cesiumWidget.scene);
    dataSourceDisplay.getDataSources().add(czmlSource);
    dataSourceDisplay.update(cesiumWidget.clock.currentTime);
  </script>
</body>
</html>
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+unsubscribe@googlegroups.com.

linde...@gmail.com

unread,
Jun 6, 2013, 2:47:28 PM6/6/13
to cesiu...@googlegroups.com
This is perfect. Thank you.
Message has been deleted

Ed Mackey

unread,
Sep 26, 2013, 2:59:10 PM9/26/13
to cesiu...@googlegroups.com
        --Ed.



On Thu, Sep 26, 2013 at 1:34 PM, JARSS <ja...@meicompany.com> wrote:
The previous example no longer seems to work as it appears DataSourceDisplay now requires a DataSourceCollection as a parameter and when I make that update, I don't see the polygon.  Can you post an updated example?
Reply all
Reply to author
Forward
Message has been deleted
0 new messages