Cesium中的鼠标事件可以通过:ScreenSpaceEventHandler来捕捉,查看官方文档可知,Handles user input events. Custom functions can be added to be executed on when the user enters input.基于屏幕空间,可以自定义用户的输入交互事件。
ScreenSpaceEventType目前支持:
LEFT_CLICK、LEFT_DOUBLE_CLICK、LEFT_DOWN、LEFT_UP、MIDDLE_CLICK、MIDDLE_DOWN、MIDDLE_UP、MOUSE_MOVE、PINCH_END、PINCH_MOVE、PINCH_START、RIGHT_CLICK、RIGHT_DOWN、RIGHT_UP、WHEEL
等事件可以绑定。
以鼠标滚轮放缩事件为例:
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
// zoom control
handler.setInputAction(zoom, Cesium.ScreenSpaceEventType.WHEEL);
function zoom(movement) {
require(["Cesium"],function(Cesium){
TODO: your code
});
}
官方API-ScreenSpaceEventType:
http://cesiumcn.org/docs/ScreenSpaceEventType.html?classFilter=ScreenSpaceEventType
官方API-ScreenSpaceEventHandler
http://cesiumcn.org/docs/ScreenSpaceEventHandler.html?classFilter=ScreenSpaceEventHandler