Hello,
I can’t figure out why I cannot access the entities of a czml datasource after it has been c
This code works OK:
var czmlData = Cesium.CzmlDataSource.load(‘…/sampledata/Otto.czml’);
czmlData.then(function(x) {
viewer.dataSources.add(x); => Entity is visible OK
viewer.zoomTo(x); => Entity is zoomed to OK
viewer.trackedEntity = x.entities.getById(‘Otto’); => Entity is tracked OK (this leads me to believe that the datasource is working OK)
});
This code fails to access entity with getById()
var czmlData = new Cesium.CzmlDataSource();
czmlData.load(‘…/sampledata/Otto.czml’);
*viewer.dataSources.add(czmlData); *=> Entity is visible OK
*viewer.zoomTo(czmlData); *=> Entity is zoomed to OK
var id = czmlData.entities.getById(‘Otto’);
console.log(id); => Result in console:‘Undefined’. But no error message in the console
This code fails also but does throw a error message in the console:
var czmlData = new Cesium.CzmlDataSource.load*(‘…/sampledata/Otto.czml’); *!! Notice the load being called directly
*viewer.dataSources.add(czmlData); *=> Entity is visible OK
*viewer.zoomTo(czmlData); *=> Entity is zoomed to OK but screen remain stuck on LOADING
var id = czmlData.entities.getById(‘Otto’);
*console.log(id); => Result: *Uncaught TypeError: Cannot read property ‘getById’ of undefined (on line 70)
So, aside from the small point I don’t understand why in case 2 there is no error message and in case 3 there is; my major question is, why is czmlData undefined in cases 2 and 3 while, based on the showcase CZML custom properties, it should work (https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=CZML%20Custom%20Properties.html&label=All)
Many thanks in advance,
Filip S.