Cesium Help

I have a small project that has the following requirements: Present a Globe, Zoom in, at a given height, present lots of objects.

Once the objects are displayed, pick/select an object, give some unique information about the object; Give an interface to the user to update attributes of the object and then refresh the screen to show the updated information.

I have been able to CesiumViewerWidget to do the zoom, loadczml, but how do I select an object and get information about it that is loaded from a czml? I would like to do what http://cesium.agi.com/LotsOfSatellites/ is doing but can't find a sample code that does what it is doing. Could anyone point me in the right direction? Thanks

/Raghu/

The CesiumViewer has an onObjectSelected property that you can use to be notified when an object is selected. This is the mechanism that the LotsOfSatellites demo uses to display details about satellites:

function onObjectSelected(selectedObject) {

if (selectedObject && selectedObject.dynamicObject.id) {

// loadJson from a web service using selectedObject.dynamicObject.id

// and create HTML overlay

}

}

on(widget, ‘ObjectSelected’, onObjectSelected);

This uses dojo/on to attach the listener but if you prefer you can just assign the onObjectSelected property, either at construction time or afterward.

One thing to be aware of, though, is that the CesiumViewerWidget API is likely to change substantially in the future as we work toward a framework-independent set of widgets.

Thanks Scott. I was able to use the to get access to the ID of the objects created by czml. I was trying hard to make my way to the dynamicObject.label.text but just can't seem to find my way :-). But I guess I can use the ID as my access to another web service as you state.

Is there a way to read or set an objects attributes? I seem to only get a array each time;

Sorry but I'm new to all this and that is why I asked. Thanks for your help with at least allowing me to get access to the objectID.

You can evaluate the label’s text property at a given time by calling getValue(time). In general, because any CZML property can vary over time, you need to call getValue to get a normal string value out.

function onObjectSelected(selectedObject) {

if (selectedObject) {

var dynamicObject = selectedObject.dynamicObject;

if (dynamicObject) {

var label = dynamicObject.label;

if (label) {

var textProperty = label.text;

if (textProperty) {

var time = widget.clock.currentTime;

var currentText = textProperty.getValue(time);

}

}

}

}

}

Also note that a selected object may not have a label property, or a text property within that label, so you need to check whether the properties exist before accessing them.