cesiumjs – How to get the positions of the polyline from a pick ?

var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(click) {
    var pickedObject = viewer.scene.pick(click.position);
    
    if (Cesium.defined(pickedObject) && (pickedObject.id)) {
        console.log(pickedObject.id.polyline.positions.getValue(viewer.clock.currentTime));
    }
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

To set the positions to a new value, you can do

pickedObjects.id.polyline.positions = Cesium.Cartesain3.fromDegreesArray([lat, lon, lat, lon,...);
Share

Leave a Reply

Your email address will not be published. Required fields are marked *