How to share custom Sandcastle examples

Click to get position

This is often useful if you’re trying to create any custom geometry on the map (like create a polygon or add a label):

var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(result) {
    var worldPosition = viewer.scene.pickPosition(result.position);
    var carto = Cesium.Cartographic.fromCartesian(worldPosition);
    console.log(carto); //Or print the worldPosition for the Cartesian3 coordinate.
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1 Like