Interact with DynamicObject or object from czml with the mouse.

Hello everybody,

I’m searching for a way to know when a visible object like a label,

is targeted by the mouse cursor.

Is it possible to have a callback function for some specifics events in the czml ?

Something like { “label”: { “onmousedown”: function…

Thanks in advance.

Hi,

We currently don’t have a way to specify this kind of behavior directly in CZML. Part of the problem is that CZML is JSON, not JavaScript, so we can’t include function definitions directly.

What you can do, though, is use the normal Cesium API to pick the primitive that’s under the mouse cursor (see the Picking Sandcastle example). When objects are created from CZML, the primitives that are returned from the pick will have a “dynamicObject” property, containing a reference back to the DynamicObject associated with that primitive. You can then get the object’s ID, or evaluate other CZML properties if needed.

Scott

Hi,

Thanks for your answer,

Maybe you could implement something like “onmousedown”: “function id”.

The real function can then be called from a specific stack.

About the picker, i use CesiumWidget and not Sandcastle.

But, i think the important part is around scene.pick(movement.endPosition); …

So i’ll try it.

Thanks!

Nice, it’s working well :wink:

Thank you!