Event listener for moving vehicle position

Hello Forum.

I might be getting close to a solution, but I'm putting this to the forum for a possible answer.
I want to display dynamic position information of a vehicle as it's moving.

Say I have dragged a CZML file onto the map and in the code I have a pointer to the Entity. What object's listener do I use to achieve this? Take a look at this demo screenshot (shows position info as vehicle is moving ).

I have tried entity.definitionChanged; but the definition has not really changed, so this would not work. Is there a basic demo in the tutorials on event handling to acquire position data of a moving vehicle (Entity)?

Thanks in advance for sharing.

Maybe Object.observe?

However this is still an experimental function that’s only supported on a few browsers according to the website. Otherwise I suppose you’ll have to make a function that continually checks the values each frame unless Cesium has a event listener I don’t know about.

Yeah, looking through the docs I'm not seeing the event firings necessary. I'll start looking for that frame refresh event.


I would recommend just subscribing to the Scene’s postRender event and evaluating the position there.


Kevin is correct. An event based system would have way too much overhead for tracking entity values over time, since in many cases they change every frame. subscribing to scene.postRender once and then polling the value is they way to go.

Keep in mind that the value of the entity isn’t actually changing, it’s the simulation time that is changing, and then the scene is updated to simply reflect the state of the entities at that time. The value of the entity is actually defined over the interval of time is represents. You can query a value at any time independent of what the current simulation time is.

Thank you Kevin and Matthew! I'm off and running with postRender. Hey, while were're in the subject of the Entity, the API does not seem to provide a method to get all the original longitude, latitude, elev (X,Y,Z) of the entity that was in the loaded CZML. I want to grab all original data in { position: cartographicDegrees : ... } (I need this for a boundary crossing bit of code).


Unfortunately we don’t preserve the position in it’s original form; you best bet is to get the position value and convert back to cartographic (using Ellipsoid.WGS84.cartesianToCartographic : http://cesiumjs.org/Cesium/Build/Documentation/Ellipsoid.html#cartesianToCartographic