Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

77
Views
Load Czml FILE in CesiumJS

I struggle to load my czml file without copying its content inside my JS script in Cesium. I would like to load the file using its url but I don't manage to do it.

var czml = "test_trace.czml";
var viewer = new Cesium.Viewer("cesiumContainer", {terrainProvider: Cesium.createWorldTerrain(), baseLayerPicker: false, shouldAnimate: true,});

viewer.dataSources.add(Cesium.CzmlDataSource.load(czml)).then(function (ds) {
    viewer.trackedEntity = ds.entities.getById("path");
});

where czml is not the content of the file but the file itself. Any idea ?

Thanks a lot

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

EDIT: A code snippet was added to the original question that contains a small error. The .then clause requires a promise, which is returned by .load but not returned by .add. I recommend this phrasing instead:

Cesium.CzmlDataSource.load(czml).then(function (ds) {
    viewer.dataSources.add(ds);
    viewer.trackedEntity = ds.entities.getById("path");
});

In the above, .load returns the promise, and .then waits for the promise to resolve. The resolved dataSource is then added to the viewer, and a tracked entity is chosen. Here's a live demo with tracking.


Original Answer:

Make sure czml is a string containing the URL. Also, the resulting DataSource needs to be added to the viewer to become visible. Check the console for errors to see if the URL was invalid or inaccessible to the app.

Here's a live demo.

The critical lines in this demo are:

var viewer = new Cesium.Viewer("cesiumContainer", {
  shouldAnimate: true,
});

viewer.dataSources.add(
  Cesium.CzmlDataSource.load("../SampleData/simple.czml")
);

In this case, the web server is offering a CZML file at the listed relative URL.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!