Retrieving the height of a polygon in CesiumJS

Hello Everyone
I am trying to display the heights of polygons that I created using CesiumJS when I click on them. I am able to get the coordinates, but I am having trouble getting the height information. Thank you in advance for your support.

Would you please provide a working sandcastle of what you have now?

What do you mean when you say “coordinates”? Do you mean that you can get a Cartesian3?

To get height above the WGS84 ellipsoid, you can convert a Cartesian3 to a Cartographic and take the height of the result.

const height = Cartographic.fromCartesian(coordinate).height;

Hello @Erixen_Cruz!
Firstly , thanks for your reply, I can share with you an example of a function that I have written to perform this task below:

var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
        handler.setInputAction(function(click) {
            var pickedObject = viewer.scene.pick(click.position);
            if (Cesium.defined(pickedObject) && instanceof Cesium.Entity) {
                var cartesian = viewer.scene.globe.pick(, viewer.scene);
                if (Cesium.defined(cartesian)) {
                    var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
                    var longitude1 = Cesium.Math.toDegrees(cartographic.longitude);
                    var latitude1 = Cesium.Math.toDegrees(cartographic.latitude);
                    var height1 = cartographic.height;
                    // var height1 = Cesium.Ellipsoid.WGS84.geoidHeight(longitude1, latitude1); // also i tried this method but returned null 
                    console.log('longitude1, latitude1, height1);
        }, Cesium.ScreenSpaceEventType.LEFT_CLICK);

While I am able to successfully retrieve the latitude and longitude information, I am encountering an issue where the output for the height is returning numerical values rather than the correct polygon height.

I can also provide you with an example of the output below:

longitude :26.35883648129588 latitude: 40.09446384834312 height: 39.57011483825242

but the polygon height value is 152.5 at these coordinates

true output: longitude :26.35883648129588 latitude: 40.09446384834312 height: 152.5

I would like to express my gratitude in advance for your assistance.

Maybe you want pickPosition instead of pick. See this sandcastle Cesium Sandcastle. May be able to help you better with a working sandcastle demonstrating what you are doing.