I would like to be able to add points or other geometry with user mouseclicks on the map. Here’s what I’ve tried so far, but nothing shows up when I click, even though I know it is reading the mouseclick position data.
var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
var points = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
handler.setInputAction(function(movement) {
console.log(Cesium.Cartesian3.clone(movement.position));
point.add({
position : Cesium.Cartesian3.clone(movement.position),
color : Cesium.Color.YELLOW
});
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
My only thought so far is that the positions being recorded by the mouse do not look like actual map positions but are more like the x and y coordinates for the viewer window/screen. So how might I get the mouse position to register what the map position is instead of the screen one. And/or is there another error you’re seeing with my script?