-
viewer.entities.getById returns nothing
-
viewer.entities.values is empty
What am I missing?
Thank you
viewer.entities.getById returns nothing
viewer.entities.values is empty
What am I missing?
Thank you
OK, I’ve found CzmlDataSourse.entities.
But how can I access ALL entities regardless of their source?
Hey Alexander,
I did something similar where I wanted to count all the current entities in my Cesium application. You can set a variable such that DataSources = viewer.dataSources;
This gives the DataSourceCollection for the viewer. This should contain all the data sources you have, including the CzmlDataSource. From here I just used a for loop that is went for the length of the collection. In your case you could do then call something like DataSources.get[i].entities.getById(id); within the loop. If it returns undefined continue looping to the next data source and if it finds what you’re looking for break out of the loop. There are a lot of different ways to work out the details, but that hopefully that can help you access all entities.
I loop through all the datasources in the viewer to find the object I want, regardless of the datasource type:
var dataSources = viewer.dataSources;
if (dataSources.length > 0) {
//loop through datasources to find entities with the selected object’s id.
for (var x=0;x<dataSources.length;x++) {
console.info('datasource: ', dataSources.get(x));
var matchingEntity = dataSources.get(x).entities.getById(objectId);
}
}
``
Bart
OK, thank you.
And to find ALL entities we need to check viewer.entities too.