[cesium-dev] How to iterate data from GeoJsonDataSource

fromUrl loads data asynchronously. If you want to access the data after loading, use the loadUrl method, and use .then to have your function called when the data is loaded.

var dataSource = new Cesium.GeoJsonDataSource();

dataSource.loadUrl(’…/…/SampleData/ne_10m_us_states.topojson’).then(function() {

console.log(dataSource.entities.entities);

});

viewer.dataSources.add(dataSource);

There’s a Sandcastle demo that does this too: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=GeoJSON%20and%20TopoJSON.html&label=Showcases

Also, just in case it wasn’t an accident. Please don’t post the same message multiple times.

Hi Scott,

Thank you! It works now.

Renyuan

Thanks for reminding! Sorry for duplicate posts… that’s because I found a typo in my previous post and I don’t know how to edit it…