I load in a CZML file into my app.js file [both files are provided below].
I'm able to access the name and id fields but not the position field. The position field contains cartographic values as 'time, longitude, latitude, altitude'. I'd like to access sets of these cartographic values so I can display them. For example, for the example below, I'd like to access position[0] as '0.00,-4.6,-38.4,250'. How do I do this?
I load in the data using 'Cesium.CzmlDataSource.load' as shown below. I'm also able to attach a new field like 'model' but not access the position field.
CZML file
[{
"id":"document",
"name":"test",
"version":"1.0",
},
{
"id":"field1",
"name":"one",
"position":
{
"cartographicDegrees": [
0.00,-4.6,-38.4,250,
0.00,-4.607,-38.491,249,
0.15,-4.6079,-38.48,249]
}
}
]
app.js
(function () {
"use strict";
var viewer = new Cesium.Viewer('cesiumContainer');
var readPromise = Cesium.CzmlDataSource.load('./test.czml');
// Save a new drone model entity
var testobj;
readPromise.then(function(dataSource)
{
viewer.dataSources.add(dataSource);
var ds = viewer.dataSources.get(0);
console.log("# of ds loaded: " + ds.entities.values.length);
console.log("ds id: " + ds.entities.values[0].id);
console.log("ds name: " + ds.entities.values[0].name);
// Output of following line - [object, Object] ???
console.log("ds name: " + ds.entities.values[0].position);
// Get the entity using the id defined in the CZML data
drone = dataSource.entities.getById('field1');
// Attach a 3D model
drone.model = { uri : './Source/SampleData/Models/drone.glb' };
});
}());