czml file syntax error

I am trying to read data from a czml file and display the data on the map. However, when I call the file in, it gives me a syntax error. My code is below (taken from Sandcastle):

function czmlSatellites(){
    viewer.dataSources.removeAll();
    var czmlDataSource = new Cesium.CzmlDataSource();
    czmlDataSource.loadUrl('path/Vehicle.czml').then(function(){
        viewer.dataSources.add(czmlDataSource);
        viewer.homeButton.viewModel.command();
    }
}

Error message:
syntax error Vehicle.czml

My Vehicle.czml is taken from the cesium folder, under 'Apps/CesiumViewer/Gallery/'

Lydia

It looks like you’re missing a ); at the end of the call to then.
Try:
function czmlSatellites(){
viewer.dataSources.removeAll();
var czmlDataSource = new Cesium.CzmlDataSource();
czmlDataSource.loadUrl(‘path/Vehicle.czml’).then(function(){
viewer.dataSources.add(czmlDataSource);
viewer.homeButton.viewModel.command();
});
}

Sorry, I just mistyped my code when I was typing my question. The ); is in my original code.

It seems like the syntax error is coming from my czml file. It says the error is in the first line, which is just an opening bracket ([).

Thanks for your help,
Lydia

I still cannot figure out why it's complaining about the opening bracket, [. Do you have any idea why?

Thanks,
Lydia

Is this in Firefox? If the CZML file is not being served with the “application/json” Content-Type header, Firefox will log “syntax error” to the console, but otherwise loads and parses the JSON correctly. I can reproduce the console error with CesiumViewer running in the Cesium development server by removing “czml=application/json” from Tools\proxy\mime.properties, but the CZML file still works after loading.

I can’t find any relevant links at the moment, but this error message seems to be a bug in Firefox. Check your web server configuration to make sure the Content-Type is set correctly, otherwise you can ignore that error.

I am struggling with the same problem. I have successfully written a CZML file from a sample.kml via Cesium Language Converter and then tried to drag and drop it to the Cesium Viewer (in Firefox and Chrome). The result is a syntax error: ( SyntaxError: Unexpected number at Object.parse). Looking at the error from the console, it is complaining about the opening bracket of the CZML file. Only the CZML files that are already supplied in the Cesium repository work without any problems.

Has anyone managed to resolve this issue?

Thanks,
Matej

Can you post the CZML file you created?

I couldn’t find the file that gave me the above-described error. I tried to replicate the error, but without any luck. However I also tried to convert another KML test file (city-test.kml), and doesn’t seem to work correctly. The czml-writer program does indeed transform the KML to CZML but fails to visualize it in Cesium Viewer. I also tried to convert city-test-01.kml file, but the generated output file for CZML conversion was empty. Is there a problem with the initial KML file, or is there a syntax mistake in the CZML file?

city-test.kml (228 KB)

city-test.czml (249 KB)

Test file:

city-test.kml (search location: Berlin)

The online KML converter is going away; it is recommended that you use the Cesium kml branch instead. (which should load your sample CZML without problems). I’m going to write a post some time soon regarding using the kml branch; so keep a look out for it.

Matthew,

Checking to see if you've yet posted on the kml branch you refer to here (in between all the activity going on...). I am a amateur programmer with some KML <<www.geo-animate.com/War-of-Movement>>. I want to migrate it because of Cesium is more accessible to my audience and allows more flexibility. I have followed the Cesium/KML branch at github without success (can't find newly created CesiumLanguageConverter.exe), which underscores how much of a amateur I am.

Many thanks, erik

The CesiumLanguageConverter is no longer supported. Instead we are adding native KML support to Cesium. This work is currently being done on the kml branch. If you want to try it you can clone Cesium locally and build that branch. We still expect to have an official Cesium release with some level of native KML support out before the end of the year.