Class: CustomTag

CustomTag

CustomTag已停止更新,推荐使用功能更丰富的标注对象Marker


<protected> new CustomTag()

Deprecated:
  • 用户自定义标签类 一般通过api.customTag调用其方法
See:

Extends

Methods


add(data, fn)

添加一个或多个CustomTag对象

Parameters:
Name Type Description
data object | array

CustomTag类的对象或者数组,对于每一个CustomTag,支持以下属性:

  • id (string) 字符串类型的ID

  • groupId (string) 可选,Group分组

  • userData (string) 可选,用户自定义数据

  • coordinate (array) 坐标值,取值示例

  • contentURL (string) 网页URL(本地地址或者网络地址),注意:本地地址中不能有空格

  • contentSize (array) 网页窗口尺寸: [width, height],数组元素类型:(number),数组元素取值范围:[任意正整数]

  • popupURL (string) 弹出窗口的网页地址,资源引入说明

  • popupSize (array) 弹出窗口的尺寸:[width, height],数组元素类型:(number),数组元素取值范围:[任意正整数]

  • pivot (array) 中心点:[0.5,0.5],数组元素类型:(number),数组元素取值范围:[0~1]

  • range (array) 显示范围:[min, max],数组元素类型:(number),数组元素取值范围:[任意正整数]

  • autoHidePopupWindow (boolean) 是否自动关闭弹出窗口,默认会自动关闭:true

  • popupPos (array) 弹窗位置: [x, y],数组元素类型:(number),数组元素取值范围:[任意正整数]

fn function

可选的回调函数,请参考二次开发:异步接口调用方式

Example
let o = {
            id: 'ct1',
            coordinate: [495113.71875, 2491218, 0.4],
            contentURL: HostConfig.Path + '/samples/popup/simple.html?icon=images/ctag1.png&title=北医三院&address=海淀区花园北路',
            contentSize: [220, 52],
            popupURL: HostConfig.Path + '/samples/popup/chart.html',
            popupSize: [600, 480],
            pivot: [0.5, 0.5],
            range: [1, 5000],
            autoHidePopupWindow: true,
            popupPos: [100,200]
        }
        __g.customTag.add(o);

clear(fn)

删除场景中所有的CustomTag

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式


delete(ids, fn)

删除一个或多个CustomTag对象

Parameters:
Name Type Description
ids string | array

要删除的CustomTag对象的ID或者ID数组(可以删除一个或者多个)

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


focus(ids, distance, flyTime, rotation, fn)

自动定位到合适的观察距离

Parameters:
Name Type Description
ids string | array

CustomTag对象的ID或者ID数组

distance number

可选参数,观察点距离目标点(被拍摄物体)的距离,取值范围:[0.01~任意正数],如果设置为0或者不设置,系统自动计算

flyTime number

可选参数,相机飞行的时间,取值范围:[0~任意正数],单位:秒,默认值2秒

rotation array

可选参数,相机旋转的欧拉角:[Pitch,Yaw,Roll],数组元素类型:(number),取值范围:Pitch[-90~90] Yaw[-180~180] Roll[0]

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


focusAll(distance, flyTime, rotation, fn)

自动定位到能观察所有CustomTag对象的合适距离

Parameters:
Name Type Description
distance number

可选参数,观察点距离目标点(被拍摄物体)的距离,取值范围:[0.01~任意正数],如果设置为0或者不设置,系统自动计算

flyTime number

可选参数,相机飞行的时间,取值范围:[0~任意正数],单位:秒,默认值2秒

rotation array

可选参数,相机旋转的欧拉角:[Pitch,Yaw,Roll],数组元素类型:(number),取值范围:Pitch[-90~90] Yaw[-180~180] Roll[0]

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


get(ids, fn)

根据ID获取CustomTag的详细信息

Parameters:
Name Type Description
ids string | array

要获取的CustomTag对象ID或者ID数组(可以获取一个或者多个)

fn function

可选的回调函数,请参考二次开发:异步接口调用方式

Example
CustomTag的详细信息
{
            "id":	"ct1",
            "groupId":	"",
            "userData":	"",
            "coordinate":	[495113.718750, 2491218.000000, 0.400000],
            "contentURL":	"G:\\TEMP\\Explorer\\SDK\\JS/simple.html?icon=images/ctag1.png&title=北医三院&address=海淀区花园北路",
            "popupURL":	"G:\\TEMP\\Explorer\\SDK\\JS/chart.html",
            "contentSize":	[220.000000, 52.000000],
            "popupSize":	[600.000000, 480.000000],
            "pivot":	[0.500000, 0.500000],
            "range":	[1.000000, 5000.000000],
            "autoHidePopupWindow":	1
        }

hide(ids, fn)

隐藏CustomTag

Parameters:
Name Type Description
ids string | array

CustomTag对象的ID或者ID数组

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


hideAll(fn)

隐藏所有CustomTag

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式


setAutoHidePopupWindow(id, newVal, fn)

设置是否自动关闭标签的弹出窗口

Parameters:
Name Type Description
id string

标签的唯一标识符ID

newVal boolean

是否自动关闭标签的弹出窗口

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


show(ids, fn)

显示CustomTag

Parameters:
Name Type Description
ids string | array

CustomTag对象的ID或者ID数组

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


showAll(fn)

显示所有CustomTag

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式


update(data, fn)

修改一个或多个CustomTag对象

Parameters:
Name Type Description
data object | array

CustomTag类的对象或者数组,参考add方法

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


updateBegin()

用于批量多次修改对象的属性

在开始修改之前调用updateBegin,然后可以多次调用setXXX方法,最后调用updateEnd提交修改更新数据
注意:
updateBegin不是异步调用,不需要await,也没有回调函数参数

Inherited From:
Overrides:
Example
__g.xxx.updateBegin();
for (let i = 0; i < 1000; i++) {
     __g.xxx.setColor(i, Color.Yellow);
} 
__g.xxx.updateEnd(function () {
     log('update finished!');
});

updateEnd(fn)

用于批量多次修改对象的属性,与updateBegin配套使用
注意:
updateEnd是异步调用,可以用回调函数也可以await

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式

Inherited From:
Overrides: