I can measure horizontally between two points - how can I do the same vertically?

1. A concise explanation of the problem you’re experiencing.

At the moment, I can add points by double clicking on the terrain, when there are more than one point, a line is drawn between them and the (horizontal) distance is added to a label along the line.

I am trying to figure out how to do the same thing, but for vertical distances I can’t figure out how to add a point in a vertical context, an example would be to measure the height of a building and not just the width/depth.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

I have a Sandcastle link if that is easier:


To reproduce, double click anywhere a couple of times to add some points and for the line to be drawn between them. The distance between the points should be calculated and displayed, I’d like to calculate the vertical distance, for example, the height of a building.

I am trying to calculate the height of the click but I always seem to get ‘no cartesian’ here:

handler.setInputAction(function(click) {

var clickPosition = viewer.camera.pickEllipsoid(click.position);

var cartesian = viewer.scene.pickPosition(clickPosition);

if (cartesian) {


var cartographic = Cesium.Cartographic.fromCartesian(cartesian);

height = cartographic.height.toFixed(2) + ’ m’;

} else {

console.log(‘no cartesian’);


lastPosition = clickPosition;


}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I would love to figure out how to measure vertical distances in addition to horizontal ones, and eventually do the same with a polygon.

4. The Cesium version you’re using, your operating system and browser.

Cesium 1.61, OS X and Chrome.

Try this:

The problem of no cartesian will be resolved

handler.setInputAction(function(click) {

var cartesian = viewer.scene.pickPosition(click.position);


if (Cesium.defined(cartesian)) {


var cartographic = Cesium.Cartographic.fromCartesian(cartesian);

cartographic.height = cartographic.height.toFixed(2) + ’ m’;

} else {

console.log(‘no cartesian’);


Ah, thank you so much, I have no idea why using variable assigned to click.position would work though.

I’m assuming I’d need to convert the cartographic back to a cartesian in order to pass it to my addPoint method?

It basically does

addPoint(position) {

var point = {




I’ve just realised my sandcastle link isn’t the right one, I am sure it worked earlier but I can recreate it.

If you haven’t seen it, the ion SDK (which builds some additional features onto CesiumJS) does have measurement tools for horizontal, vertical, or just perpendicular to any surface:


We’re working on making it available on the Cesium ion platform so it’s easier to make these kinds of measurements!

Hi Omar,

I actually just found that link a couple of hours ago.

Do you know if the ion SDK can be used but with non hosted ion assets?

e.g. We already have all the data we need so we don’t need any tile generation or cloud hosting offered by the ion service, but the SDK might be an option if it can be used on it’s own.

Also, here are some images to better explain, from the first picture you might expect the yellow dot to be the top of the building when it’s really a horizontal point in the distance.

Screenshot 2019-09-23 at 14.40.42.png

Screenshot 2019-09-23 at 14.41.19.png

Yes, in fact that’s currently how it’s available. It’s part of the Cesium ion on-premise tools, so you can use it locally/offline/in your own application.

You can request an evaluation here: https://cesium.com/contact/sales/

Thanks Omar,

I submitted an enquiry yesterday.