Hello,
I load my datasource from viewerDragDropMixin but I need to change it before display... I need to call createOnLoadCallback, right?
stroke: Cesium.Color.HOTPINK,
fill: Cesium.Color.PINK.withAlpha(0.5),
strokeWidth: 3
viewer.extend(Cesium.viewerDragDropMixin, {
clearOnDrop : false
});
Then createOnLoadCallback... how?
Thanks
Viewer.dataSources will be a DataSourceCollection, which has a dataSourceAddded event you can subscribe to in order to get the dataSource you just added to the viewer.
Thanks,
Gabby
Hello Gabby,
var dataSourceCollection=viewer.dataSources;
dataSourceCollection.dataSourceAdded.addEventListener(function(collection,datasource){
var p = datasource.entities.values;
for (var i = 0; i < p.length; i++) {
console.log(p[i].id);
console.log(p[i].name);
console.log(p[i].polyline.material);
}
});
Console:
TypeError: Cannot read property 'material' of undefined
undefined
d317ad46-6b1e-4424-8518-36e817603405
Cant get material to change it
I’m assuming not all of the entities are polylines. Add a check before accessing any specific properties.
var dataSourceCollection=viewer.dataSources;
dataSourceCollection.dataSourceAdded.addEventListener(function(collection,datasource){
var p = datasource.entities.values;
for (var i = 0; i < p.length; i++) {
console.log(p[i].id);
console.log(p[i].name);
if (Cesium.defined(p[i].polyline) {
console.log(p[i].polyline.material);
}
}
});
``
e21cbcb0-cc5a-4b15-81ef-67f61daa4044
undefined
4be686b4-8864-4344-873a-c3af7bd15127
undefined
4c5f7632-c577-4c82-b959-c1ad19624970
undefined
326588f0-f43f-4279-b656-a9b72f1da969
undefined
…
29f8aeb0-e01b-4ec4-a941-d4993eed5d80
undefined
81f49776-3e6d-47f5-a8dd-97b068f67b31
undefined
6988d75e-a122-4089-8943-374e496fd45e
undefined