界面
事件
new Event()
实例化
返回:
- 实例化Event对象
详情:
实例化
Event
对象,可以调用事件模块中的方法示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const event = new kapi.Event()
console.log(event)
支持的事件监听方法
事件监听 | 参数 |
---|---|
帧率 | KAPI_CONST.EVENT.FPS |
绘制光流 | KAPI_CONST.EVENT.DRAW_LIGHT_FLOW |
获取点 | KAPI_CONST.EVENT.DRAW_GET_POINT |
标注击 | KAPI_CONST.EVENT.MARKER_CLICK |
addEventListener()
添加事件监听
返回:
- 添加事件后的回调
详情:
添加事件监听
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const event = new kapi.Event()
// 配合帧率启用接口监听帧率值变化
event.addEventListener(KAPI_CONST.FPS, response => {
console.log(response)
})
removeEventListener()
删除事件监听
返回:
- 删除事件后的回调
详情:
删除事件监听
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const event = new kapi.Event()
// 配合帧率启用接口监听帧率值变化
event.addEventListener(KAPI_CONST.FPS, response => {
console.log(response)
})
// 10秒后删除事件监听
setTimeout(async () => {
let response = await marker.removeEventListener(KAPI_CONST.FPS)
console.log(response)
}, 10 * 1000)
- 参考: KAPI_CONST