Google Map Migration: can't get the correct KML file altitude height.

I have a KML file which consist of only one KML Point with coordinates as <coordinates>-76.43594397,36.77823129,33.3030576</coordinates>
. I am trying to get this point's longitude latitude and altitude(height) by triggering a CLICK event on this KML point. I used the code below to trigger the click event:

var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(click) {
   var pickedObject = viewer.scene.pick(click.position);
   var position =;
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);

By using this function, neither the position or the height is correct. Then I replaced with another snippet as below:

var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(click) {
  var ellipsoid = viewer.scene.globe.ellipsoid;
  var cartesian =, ellipsoid);
  var cartographic = ellipsoid.cartesianToCartographic(cartesian);
  var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2);
  var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2);
  var heightString = cartographic.height.toFixed(2);
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);

After utilizing this code on the click event on the KML point shown on the map, I can finally get the proper longitude and latitude, but the heightString always remains zero.

I have been stuck on this part for a long time and I really don't know which part is wrong. Please help me out of this. Is this snippet not suit for my situation or I have to convert the first coordinate to get the real altitude?

At a first guess, it might be due to your use of pickEllipsoid(). I don’t think that’s going to return a meaningful altitude value. You probably need to get the coordinates, then use sampleTerrain(). See prior discussions in this forum for more info, as well as .


Have you seen this demo?

It uses viewer.scene.globe.pick(ray, viewer.scene); to get the position on the terrain that includes height.



Hi Mark,
I tried the sampleTerrain, however the return result is still not correct. Do you have any recommendation on how to improve it? Thanks.

I have checked the demo and tried the coordinate on the demo page, the value is a negative with correct number. But when I paste the code into my project, I cannot get the value. How should i setup Cesium, do i have to load anything else apart from just the code from demo?

One thing to keep in mind altitude/elevation in Cesium is that the with terrain, at the moment, cesium is using ellipsoid elevations.

If you are trying to render a kml absolute elevation of 33 meters, this is 33 meters above sea level, or an orthemetric elevation.

the difference between the two elevations is a geoid offset. depending on where you are the geoid offset is going to be different

the bing maps elevation api has an endpoint for getting the geoid offset (estimated to the nearest meter)

See the section: "Get the offset of the geoid sea level Earth model from the ellipsoid Earth model at a set of latitude and longitude coordinates. "

looking at the long lat , -76.43594397,36.77823129

the ellipsoid elevation for the provided coordinate shows the ground elevation about -28 meters , (using the cesium terrain sandbox example)

the orthimetric elevation is about 6 meters above sea level, (elevation using google earth)

the difference between the 2 is about -34 meters

the response from the bing maps geoid request gives an offset of -38, not the same value, but close enough for rendering

to show 33 meters above sea level, you will need to use 33m = (-38 or -34 ) giving (-5 or -1) as the elevation in cesium