yes , i am using some of the cesium plugins, and i am writing some of the tools. I require that feature for multiple tools or plugins has to work simultaneously.
That features are available in DOM event handling. will that possible in cesium ?
At the moment, the ScreenSpaceEventHandler is designed to only have one function per input action. However, you can create multiple SceenSpaceEventHandlers to handle this:
var handler1 = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
var handler2 = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
handler1.setInputAction(
function (click) {
console.log(“second”+click);
},
Cesium.ScreenSpaceEventType.LEFT_CLICK
);
handler2.setInputAction(
function (click) {
console.log(“first”+click);
},
Cesium.ScreenSpaceEventType.LEFT_CLICK
);
As an alternative, depending on your environment, to work around this same issue, I created a custom event emitter and made it so that, the screen space event handler just emitted an event through my shared event emitter. That allowed me to pass it around and use it as many times as I wanted
Hi Klaus,
Each ScreenSpaceEventHandler can have one event of each type, so if you set a new LEFT_CLICK on some event it will override the previous one. If you want multiple LEFT_CLICK events, you can make several new ScreenSpaceEventHandlers.
Here’s Hannah’s example code as a Sandcastle example, so you can easily try it for yourself: