界面
标注
new Marker()
实例化
返回:
- 实例化Marker对象
详情:
实例化
Marker
对象,可以调用标注模块中的方法示例:
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 marker = new kapi.Marker()
console.log(marker)
createMarker()
创建标注点对象marker
参数:
{Object} position 标注点的位置信息
{Object} attributes 标注点的属性信息
{Boolean} sync 是否要与其他客户端同步状态
position参数如下表
变量 | 类型 | 说明 |
---|---|---|
x | number | x坐标 |
y | number | y坐标 |
z | number | z坐标 |
attributes参数如下表
变量 | 类型 | 说明 |
---|---|---|
id | string | 标注的id 必填字段 |
name | string | 标注点名称 |
type | string | 标注型 |
scale | number | 标注大小比例 |
isGraphic | string | 是否是地理坐标,默认是false |
返回:
- 抬升高度后的返回信息
详情:
创建标注点,只返回一个marker对象,但不会标注到场景中。
示例:
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 marker = new kapi.Marker()
const position = {
x: 510452.4,
y: 4056732.75,
z: 50
}
const attributes = {
id: 123,
name: "测试",
type: "建筑",
scale: 0.5 ,
isGraphic: false,
visible:true
}
const markerObject = await marker.createMarker(position, attributes)
console.log(markerObject)
add()
创建标注点对象marker
参数:
{Marker} marker 标注点对象
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 抬升高度后的返回信息
详情:
创建标注点,只返回一个marker对象,但不会标注到场景中。
示例:
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 marker = new kapi.Marker()
const position = {
x: 510452.4,
y: 4056732.75,
z: 50,
}
const attributes = {
id: 123,
name: "测试",
type: "建筑",
scale: 0.5 ,
isGraphic: false,
visible:true
}
const markerState = await marker.add(marker)
console.log(markerState)
或使用 createMarker()
创建 marker
再执行add()
方法
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 marker = new kapi.Marker()
const position = {
x: 510452.4,
y: 4056732.75,
z: 50
}
const attributes = {
id: 123,
name: "测试",
type: "建筑",
scale: 0.5 ,
isGraphic: false,
visible:true
}
const markerObject = await marker.createMarker(position, attributes)
const markerState = await marker.add(markerObject)
console.log(markerState)
- 参考: createMarker()
remove()
根据marker的id删除标注点
参数:
{String | Number} id marker的id
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 删除标注点后的返回信息
详情:
根据marker的id删除标注点。
示例:
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 marker = new kapi.Marker()
const removeMarker = await marker.remove(123)
console.log(removeMarker)
clear()
清空场景中的marker
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 清空场景中的marker后的返回信息
详情:
清空场景中的marker。
示例:
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 marker = new kapi.Marker()
const clearMarker = await marker.clear()
console.log(clearMarker)
update()
更新标注点(TODO)
参数:
{Marker} marker 标注点对象
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 更新标注点后的返回信息
详情:
更新标注点。
示例:
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 marker = new kapi.Marker()
const position = {
x: 510452.4,
y: 4056732.75,
z: 50
}
const attributes = {
id: 123,
name: "测试",
type: "建筑",
scale: 0.5 ,
isGraphic: false,
visible:true
}
const markerObject = await marker.createMarker(position, attributes)
const markerState = await marker.add(markerObject)
console.log('原始标注点', markerState)
const position = {
x: 510452.4,
y: 4056732.75,
z: 50
}
const attributes = {
id: 123,
name: "中学",
type: "学校",
scale: 1 ,
isGraphic: false,
visible:true
}
const markerObject2 = await marker.createMarker(position, attributes)
const updateMarker = await marker.update(markerObject2)
console.log('更新后的标注点', updateMarker)
updateByAttributes()
更新标注点
参数:
{String | Number} id 标注点的id
{Object} attributes 标注点对象
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 更新标注点后的返回信息
详情:
更新标注点。
示例:
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 marker = new kapi.Marker()
const position = {
x: 510452.4,
y: 4056732.75,
z: 50
}
const attributes = {
id: 123,
name: "测试",
type: "建筑",
scale: 0.5 ,
isGraphic: false,
visible:true
}
const markerObject = await marker.createMarker(position, attributes)
const markerState = await marker.add(markerObject)
console.log('原始标注点', markerState)
const attributes = {
name: "中学",
type: "学校",
scale: 1 ,
isGraphic: false,
visible:true
}
const updateMarker = await marker.updateByAttributes(123, attributes)
console.log('更新后的标注点', updateMarker)
show()
根据id显示场景中的marker
参数:
{String | Number} id marker的id
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 根据id显示场景中的marker后的返回信息
详情:
根据id显示场景中的marker。
示例:
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 marker = new kapi.Marker()
// 标注点,此处省略
const showMarker = await marker.show(123)
console.log(showMarker)
hide()
根据id隐藏场景中的marker
参数:
{String | Number} id marker的id
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 根据id隐藏场景中的marker后的返回信息
详情:
根据id隐藏场景中的marker。
示例:
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 marker = new kapi.Marker()
// 标注点,此处省略
const hideMarker = await marker.hide(123)
console.log(hideMarker)
showAll()
显示场景中所有的marker
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 显示场景中所有的marker后的返回信息
详情:
显示场景中所有的marker。
示例:
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 marker = new kapi.Marker()
// 标注点,此处省略
const showAllMarker = await marker.showAll()
console.log(showAllMarker)
hideAll()
隐藏场景中所有的marker
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 隐藏场景中所有的marker后的返回信息
详情:
隐藏场景中所有的marker。
示例:
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 marker = new kapi.Marker()
// 标注点,此处省略
const hideAllMarker = await marker.hideAll()
console.log(hideAllMarker)
flyToMarker()
定位到标注点marker
参数:
{Marker} marker 标注点
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 定位到标注点marker后的返回信息
详情:
定位到标注点marker。
示例:
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 marker = new kapi.Marker()
const position = {
x: 510452.4,
y: 4056732.75,
z: 50
}
const attributes = {
id: 123,
name: "测试",
type: "建筑",
scale: 0.5 ,
isGraphic: false,
visible:true
}
const markerObject = await marker.createMarker(position, attributes)
const response = await marker.flyToMarker(markerObject)
console.log(response)
addMarkerFocus()
设置标注点点击定位
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 设置标注点点击定位后的返回信息
详情:
设置标注点点击定位。
示例:
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 marker = new kapi.Marker()
const position = {
x: 510452.4,
y: 4056732.75,
z: 50
}
const attributes = {
id: 123,
name: "测试",
type: "建筑",
scale: 0.5 ,
isGraphic: false,
visible:true
}
const markerObject = await marker.createMarker(position, attributes)
const addMarker = await marker.add(markerObject)
let response = await marker.addMarkerFocus()
console.log(response)
removeMarkerFocus()
关闭标注点点击定位
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 关闭标注点点击定位后的返回信息
详情:
关闭标注点点击定位。
示例:
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 marker = new kapi.Marker()
const position = {
x: 510452.4,
y: 4056732.75,
z: 50
}
const attributes = {
id: 123,
name: "测试",
type: "建筑",
scale: 0.5,
isGraphic: false,
visible: true
}
const markerObject = await marker.createMarker(position, attributes)
const addMarker = await marker.add(markerObject)
let response = await marker.addMarkerFocus()
// 10秒后关闭点击定位
setTimeout(async () => {
let response = await marker.removeMarkerFocus()
console.log(response)
}, 10 * 1000)
clear()
清空标注点
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 清空标注点后的回调
详情:
清空标注点。
示例:
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 marker = new kapi.Marker()
const response = await marker.clear()
console.log(response)
MarkerClickEventListener
设置标注的点击监听
参数:
{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.MARKER_CLICK, response => {
console.log(response)
})
删除标注的点击监听
返回:
- 删除标注的点击监听的返回信息
详情:
删除标注的点击监听。
示例:
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.MARKER_CLICK)