Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var viewer = new Cesium.Viewer('cesiumContainer');
var screenSpaceEventHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
//Function to add a point
function addPoint(x,y) {
var point = viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(x, y),
point : {
pixelSize : 10,
color : Cesium.Color.YELLOW
}
});
}
screenSpaceEventHandler.setInputAction(function(click) {
var mousePosition = viewer.camera.pickEllipsoid(click.position);
var cartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(mousePosition);
var ray = viewer.camera.getPickRay(click.position);
var position = viewer.scene.globe.pick(ray, viewer.scene, position);
var cartographic2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
var x2 = Cesium.Math.toDegrees(cartographic2.longitude);
var y2 = Cesium.Math.toDegrees(cartographic2.latitude);
addPoint(x2,y2);
console.log(x2, y2, cartographic2.height);
console.log(y2);
console.log(cartographic2.height);
var x = Cesium.Math.toDegrees(cartographic.longitude);
var y = Cesium.Math.toDegrees(cartographic.latitude);
//console.log(x,y);
addPoint(x,y);
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
@AkshayGore
Copy link

AkshayGore commented Jun 12, 2018

How to measure length between three points?
Thanks
Akshay Gore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment