# Event listener for moving vehicle position

**URL:** <https://community.cesium.com/t/event-listener-for-moving-vehicle-position/2011>\
**Category:** CesiumJS\
**Created:** [February 14, 2015, 5:30pm UTC](https://community.cesium.com/t/event-listener-for-moving-vehicle-position/2011 "2015-02-14T17:30:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomlep](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@thomlep](https://community.cesium.com/u/thomlep)\
**Post date:** [February 14, 2015, 5:30pm UTC](https://community.cesium.com/t/event-listener-for-moving-vehicle-position/2011/1 "2015-02-14T17:30:09Z")

</div>

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 ).

> **[The Cesium Blog | cesium.com](https://cesium.com/blog/categories/userstories/)**
>
> Cesium is geospatial. Use Cesium ion's simple workflow to create 3D maps of your geospatial data for visualization, analysis, and sharing. For developers, use the open-source CesiumJS library to create custom 3D mapping apps.

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.

---

<div class="post-metadata">

**Author:** ![Hyper\_Sonic](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hyper_sonic/32/2255_2.png) [@Hyper\_Sonic](https://community.cesium.com/u/Hyper_Sonic)\
**Post date:** [February 14, 2015, 6:45pm UTC](https://community.cesium.com/t/event-listener-for-moving-vehicle-position/2011/2 "2015-02-14T18:45:06Z")

</div>

Maybe Object.observe?

> **[Object.observe()](https://developer.mozilla.org/en-US/docs/Archive/Web/JavaScript/Object.observe)**
>
> The Object.observe() method was used for asynchronously observing the changes to an object. It provided a stream of changes in the order in which they occur. However, this API has been deprecated and removed from browsers. You can use the more...

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.

---

<div class="post-metadata">

**Author:** ![thomlep](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@thomlep](https://community.cesium.com/u/thomlep)\
**Post date:** [February 15, 2015, 10:34pm UTC](https://community.cesium.com/t/event-listener-for-moving-vehicle-position/2011/3 "2015-02-15T22:34:14Z")

</div>

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

Thanks

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [February 15, 2015, 10:53pm UTC](https://community.cesium.com/t/event-listener-for-moving-vehicle-position/2011/4 "2015-02-15T22:53:48Z")

</div>

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

Kevin

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [February 16, 2015, 3:26pm UTC](https://community.cesium.com/t/event-listener-for-moving-vehicle-position/2011/5 "2015-02-16T15:26:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![thomlep](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@thomlep](https://community.cesium.com/u/thomlep)\
**Post date:** [February 16, 2015, 3:53pm UTC](https://community.cesium.com/t/event-listener-for-moving-vehicle-position/2011/6 "2015-02-16T15:53:28Z")

</div>

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).

Thanks.

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [February 23, 2015, 3:18am UTC](https://community.cesium.com/t/event-listener-for-moving-vehicle-position/2011/7 "2015-02-23T03:18:33Z")

</div>

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](http://cesiumjs.org/Cesium/Build/Documentation/Ellipsoid.html#cartesianToCartographic)
