Created
May 4, 2018 12:46
-
-
Save AlexZeller/1452287607b0d1fad642bc3111bc531d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to measure length between three points?
Thanks
Akshay Gore