Save viewer to hard disk?

Is it possible to save the viewer (map and all objects) to a hard disk to be reopened later?

David,

If you are using CZML to push data into Cesium, it does not seem seem unreasonable that you could simply save this file (server or client generated) to the user’s local disk based on a user prompt or possibly by pushing it to a server-side process that returns a file back to the Web user.

I suspect, however, that you want to serialize Cesium’s dynamic objects (etc.) to disk. I also don’t think that would be unreasonable but might require some work on your part. The CZMLDataSource and DataSourceCollection objects seem like it would be the way to start; perhaps the Cesium developers can explain whether there is the something of a CZMLDataSource.toCZML() feature that would literally translate your data source(s) to CZML.

It occurred to me that you might be referring to saving a snapshot (image) of the Viewer in its current form to disk; is this what you mean? If so, there are a couple of ways to save the state of a WebGL scene to an image. I would start there.

I believe your first response touches on what I would like. Let me explain my situation. I have created a excel addin (c#) for analyzing traffic data, that allows me to take the data from the Excel dataModel and creates a datasource which then is added to winform (web browser) embedded cesium viewer. When I am done viewing the data in cesium I would like to be able to save it to be able to reload it another time, so I dont have to reselect the data and wait for the datasource to be created and such. So yes to be able to convert a datasource to czml would be nice.

What would be the czml structure of a DataSource with entities of polylines? Maybe instead of generating a DataSource programatically I can generate a CZML then I can just save the czml and reload it later.

It’s on the long-term roadmap to have the ability to take any DataSource and write it out to CZML; but for your use case; it sounds like the best solution would be to generate CZML directly from your Excel add-in. If you are working in .NET or Java, there’s a CZML writer library at https://github.com/AnalyticalGraphicsInc/czml-writer that you can use. It’s not quite 1.0 quality yet, but we plan on continuing to improve it going forward and use it to write all of our own CZML.

I used c# to generate a czml but I am getting this error… only in my program, if I try it in sandcastle it works fine

"Uncaught TypeError: Cannot read property ‘length’ of undefined "
localhost/maps/3rdParty/Cesium/Build/Cesium/Cesium.js:31783

``

here is sandcastle code
var viewer = new Cesium.Viewer(‘cesiumContainer’,

        {

            fullscreenElement : document.body,

            sceneMode : Cesium.SceneMode.COLUMBUS_VIEW,

            infoBox: false,

            fullscreenButton: false,

            homeButton: false,

            navigationHelpButton: false,

            navigationInstructionsInitiallyVisible: false,

            geocoder: false,

            selectionIndicator: false

        });

viewer.baseLayerPicker.viewModel.selectedImagery = viewer.baseLayerPicker.viewModel.imageryProviderViewModels[2];

viewer.extend(Cesium.viewerEntityMixin);

viewer.scene.camera.flyTo({

                    destination: Cesium.Cartesian3.fromDegrees(-111.709289 - .006, 40.263754 - .15, 20000.0),

                    up: new Cesium.Cartesian3(0.0, 0.0, 1),

                    direction: new Cesium.Cartesian3(0.3, 0.5, -.5)

                });

Sandcastle.addDefaultToolbarButton(‘CZML’, function() {

var czmlDataSource = new Cesium.CzmlDataSource();

czmlDataSource.loadUrl('https://dl.dropboxusercontent.com/u/118364876/wavetronix/czml/test.czml');

viewer.dataSources.add(czmlDataSource);

});

Sandcastle.reset = function() {

viewer.dataSources.removeAll();

};

``

I’ve tried to make heads or tails of the czml writer for .net but there is no documentation on its purpose or use, everything just leads me to the converter… so I just write text(mimicking the format of other czml files) to a document and load that as the czml

although my program loads this just fine
https://dl.dropboxusercontent.com/u/118364876/wavetronix/czml/simple.czml

``

nevermind, it seems to work just fine. I decided to redownload 1.0 and delete my existing cesium files and now it works just fine. I must have been using an older revision. Thanks for your time, and if you have any insight on how to use CZML writer please let me know.

I believe Ed Mackey plans on opening a pull request to czml-writer with some examples. Ed?