Skip to content

工具

new Tool()

实例化

  • 返回:

    • 实例化Tool对象
  • 详情:

    实例化Tool对象,可以调用工具模块中的方法

  • 示例:

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 tool = new kapi.Tool()
console.log(tool)

openGetPoint()

开启取点工具

  • 参数:

    • {String} type 返回坐标类型【 engine 返回引擎坐标; project 返回投影坐标; graphic 返回地理坐标】
  • 返回:

    • 开启取点工具后的返回信息
  • 详情:

    开启取点工具

  • 示例:

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 tool = new kapi.Tool()
const openGetPoint = await tool.openGetPoint('project')
console.log(openGetPoint)

closeGetPoint()

关闭取点工具

  • 返回:

    • 关闭取点工具后的返回信息
  • 详情:

    关闭取点工具

  • 示例:

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 tool = new kapi.Tool()
const clsoeGetPoint = await tool.closeGetPoint()
console.log(clsoeGetPoint)

GetPointListener

添加获取点的监听

  • 参数:

    • {Sting} eventName 事件监听的名称
    • {Function} callback 点击的回调
  • 返回:

    • 设置获取点的监听后的返回信息
  • 详情:

    设置获取点的监听

  • 示例:

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.EVENT.DRAW.GET_POINT, response => {
  console.log(response)
})

删除获取点的监听

  • 参数:

    • {Function} callback 点击的回调
  • 返回:

    • 设置获取点的监听后的返回信息
  • 详情:

    设置获取点的监听

  • 示例:

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.removeEventListener(KAPI_CONST.EVENT.DRAW.GET_POINT)
工具 has loaded