Class: Marker

Marker

标注点,实现对标注对象的操作
一般通过api.marker调用其方法
Marker标注点的效果图:


new Marker()

See:

Extends

Methods


add(data, fn)

添加一个或多个标注点 调用时注意:单次创建的Marker对象数量不要超过5000个,在一个工程内创建的Marker对象总数量不要超过20万个。

Parameters:
Name Type Description
data object | array

标注点的数据,可以是Object类型或者Array类型,对于每一个标注点,支持以下属性:

  • id (string) 标注点的唯一标识符

  • groupId (string) 可选,Group分组

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

  • coordinateType (number) 坐标系类型,取值范围:0为Projection类型,1为WGS84类型,2为火星坐标系(GCJ02),3为百度坐标系(BD09),默认值:0

  • coordinate (array) 标注点的位置坐标: [x, y, z],取值示例

  • anchors (array) 锚点: [x, y],设置Marker的整体偏移,取值规则和imageSize设置的宽高有关,图片的左上角会对准标注点的坐标位置。示例设置规则:x=-imageSize.width/2,y=imageSize.height

  • range (array) 可视范围: [近裁距离, 远裁距离],默认值: [10, 10000]

  • textRange (array) 文本可视范围: [近裁距离, 远裁距离],默认值: [100, 6000]

  • imageSize (array) 图片的尺寸: [width, height], 默认值[32,32]

  • fixedSize (boolean) 图片是否固定尺寸,取值范围:false 自适应,近大远小,true 固定尺寸,默认值:false

  • imagePath (string) 图片路径,支持gif动图,支持本地路径和网络路径,资源引入说明

  • hoverImagePath (string) 鼠标悬停时显示的图片路径,支持gif动图,支持本地路径和网络路径,资源引入说明

  • hoverImageSize (array) 鼠标悬停时显示的图片尺寸: [width, height], 默认值:[0,0] 使用图片自身的尺寸

  • text (string) 显示的文字

  • useTextAnimation (boolean) 是否打开文字展开动画效果,默认值:true

  • textOffset (array) 文本偏移: [x, y],默认值:[0,0]

  • fontSize (number) 字体大小,默认值:12

  • fontOutlineSize (number) 字体轮廓线大小,默认值:1

  • textBackgroundColor (Color) 文本背景颜色,默认值白色[1, 1, 1, 0.85],支持四种格式,取值示例

  • fontColor (Color) 字体颜色,默认值:黑色Color.Black,支持四种格式,取值示例

  • fontOutlineColor (Color) 字体轮廓线颜色,默认值:黑色Color.Black,支持四种格式,取值示例

  • popupBackgroundColor (Color) 弹窗背景颜色, [1.0,1.0,1.0,0.1] ,支持四种格式,取值示例

  • popupURL (string) 弹窗HTML链接或者视频文件路径,也支持rtsp协议实时视频流,资源引入说明

  • popupSize (array) 弹窗大小: [width, height],默认值:[600,400]

  • popupOffset (array) 弹窗偏移: [x, y],默认值:[0,0]

  • showLine (boolean) 标注点下方是否显示垂直牵引线,默认不显示:false

  • lineSize (array) 牵引线粗细[width, height],默认值:[0,0],如果要显示牵引线,需要将该属性设置成非0值

  • lineColor (Color) 牵引线颜色,默认值:白色,支持四种格式,取值示例

  • lineOffset (array) 牵引线偏移: [x, y],默认值:[0,0]

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

  • autoHeight (boolean) 自动判断下方是否有物体,设置正确高度,默认值:false

  • displayMode (number) 显示模式,取值说明如下:

    0:相机移动不显示,参与避让聚合

    1:相机移动时显示,参与避让聚合

    2:相机移动时显示,不参与避让聚合

    3:相机移动时不显示,不参与避让聚合

    4:智能模式,根据当前相机高度自动适配以上模式,类似金字塔lod加载效果,内置默认规则:range范围的1%内取值2,大于1%小于10%取值1,大于10%取值0

  • autoDisplayModeSwitchFirstRatio (number) 智能模式时的显示模式切换时range参数的首段比例,仅在displayMode=4时生效,取值范围:[0.01~1.0),默认值0.01,示例:如果range=[1,1000],则在[1,10]范围内dislayMode=2

  • autoDisplayModeSwitchSecondRatio (number) 智能模式时的显示模式切换时range参数的第二段比例,仅在displayMode=4时生效,取值范围:[0.01~1.0),默认值0.1,示例:如果range=[1,1000],则在[10,100]范围内dislayMode=1,大于100则dislayMode=1

  • clusterByImage (boolean) 聚合时是否根据图片路径(imagePath)分类聚合显示,即当多个marker的imagePath路径参数相同时按路径对marker分类聚合

  • priority (number) 避让优先级,默认值:0

  • occlusionCull (boolean) 是否参与遮挡剔除

fn function

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


clear(fn)

删除场景中所有的标注

Parameters:
Name Type Description
fn function

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


delete(ids, fn)

删除一个或多个标注对象

Parameters:
Name Type Description
ids string | array

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

fn function

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


deleteByGroupId(groupId, fn)

根据分组ID删除Marker

Parameters:
Name Type Description
groupId string

Marker创建时指定的分组ID

fn function

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


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

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

Parameters:
Name Type Description
ids string | array

标注对象的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)

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

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获取标注的详细信息

Parameters:
Name Type Description
ids string | array

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

fn function

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

Example
返回Marker的详细信息
{
            "id":	"m1",
            "groupId":	"",
            "userData":	"",
            "coordinateType":	0,
            "coordinate":	[495269.375000, 2491073.250000, 25.400000],
            "anchors":	[-16.000000, 32.000000],
            "range":	[10.000000, 10000.000000],
            "textRange":	[100.000000, 6000.000000],
            "imageSize":	[28.000000, 28.000000],
            "imagePath":	"C:\\Users\\Administrator\\AppData\\Roaming\\Cloud\\SDK/images/tag.png",
            "hoverImagePath":	"C:\\Users\\Administrator\\AppData\\Roaming\\Cloud\\SDK/images/hilightarea.png",
            "hoverImageSize": [28.000000, 28.000000],
            "text":	"北京银行",
            "textOffset":	[0.000000, 0.000000],
            "fontSize":	12,
            "fontOutlineSize":	1,
            "textBackgroundColor":	[1.000000, 1.000000, 1.000000, 1.000000],
            "fontColor":	[1.000000, 0.000000, 0.000000, 1.000000],
            "fontOutlineColor":	[1.000000, 0.000000, 0.000000, 1.000000],
            "popupUrl":	"C:\\Users\\Administrator\\AppData\\Roaming\\Cloud\\SDK/chart.html",
            "popupSize":	[600.000000, 400.000000],
            "popupOffset":	[0.000000, 0.000000],
            "popupBackgroundColor":	[1.000000, 1.000000, 1.000000, 0.100000],
            "lineSize":	[2.000000, 100.000000],
            "lineColor":	[0.200000, 0.700000, 0.400000, 1.000000],
            "lineOffset":	[0.000000, 0.000000],
            "autoHidePopupWindow":	1,
            "autoHeight":	0,
            "displayMode":	0,
            "priority":	0,
            "occlusioncull":	0
        }

hide(ids, fn)

隐藏标注

Parameters:
Name Type Description
ids string | array

标注对象的ID或者ID数组

fn function

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


hideAll(fn)

隐藏所有标注

Parameters:
Name Type Description
fn function

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


hideAllPopupWindow(fn)

隐藏所有标注的弹出窗口

Parameters:
Name Type Description
fn function

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


hideByGroupId(groupId, fn)

根据分组ID隐藏Marker

Parameters:
Name Type Description
groupId string

Marker创建时指定的分组ID

fn function

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


hidePopupWindow(ids, fn)

隐藏指定标注的弹出窗口

Parameters:
Name Type Description
ids string | array

标注对象的ID或者ID数组

fn function

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


setAnchors(id, newVal, fn)

设置标注的整体偏移量(修改锚点)

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

锚点新值

fn function

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


setAttachCustomObject(data, fn)

设置标注Marker贴合模型对象CustomObject或车辆载具Vehicel,设置后Marker会跟随模型运动

Parameters:
Name Type Description
data object | array

自定义对象和标注映射数据,可以是Object类型或者Array类型,对于每一个映射对象,支持以下属性:

  • markerId (string) 标注Marker对象id

  • objectId (string) 贴合的CustomObject自定义对象id或车辆载具Vehicel的id

  • offset (array) 坐标偏移量,[X,Y,Z],取值示例

fn function

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


setAutoHidePopupWindow(id, newVal, fn)

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

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal boolean

是否显示垂直牵引线

fn function

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


setCoordinate(id, newVal, fn)

设置标注的位置

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

新值

fn function

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


setFontColor(id, newVal, fn)

设置标注文本颜色

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal Color

新颜色值,支持四种格式,取值示例

fn function

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


setFontOutlineColor(id, newVal, fn)

设置字体轮廓线颜色

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal Color

新颜色值,支持四种格式,取值示例

fn function

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


setFontOutlineSize(id, newVal, fn)

设置字体轮廓线大小

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal number

新值

fn function

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


setFontSize(id, newVal, fn)

设置字体大小

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal number

新值

fn function

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


setGroupId(id, newVal, fn)

设置分组

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal string

新值

fn function

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


setHoverImagePath(id, newVal, fn)

设置鼠标悬停时显示的图片路径

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal string

新值,资源引入说明

fn function

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


setImagePath(id, newVal, fn)

设置标注的图片

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal string

新值,资源引入说明

fn function

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


setImageSize(id, newVal, fn)

设置标注图片的大小

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

新的尺寸

fn function

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


setLineColor(id, newVal, fn)

设置LineColor

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal Color

新颜色值,支持四种格式,取值示例

fn function

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


setLineOffset(id, newVal, fn)

设置LineOffset

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

新值

fn function

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


setLineSize(id, newVal, fn)

设置LineSize

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

新值

fn function

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


setOcclusionCull(id, newVal, fn)

设置是否参与遮挡剔除

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal boolean

新值

fn function

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


setPopupOffset(id, newVal, fn)

设置弹窗偏移: [x, y]

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

新值

fn function

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


setPopupSize(id, newVal, fn)

设置弹窗大小: [width, height]

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

新值

fn function

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


setPopupURL(id, newVal, fn)

设置弹窗HTML链接

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal string

新值,资源引入说明

fn function

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


setPriority(id, newVal, fn)

设置避让优先级

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal number

新值

fn function

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


setRange(id, newVal, fn)

设置标注的可见范围

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

新的可见范围值

fn function

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


setText(id, newVal, fn)

设置标注的文本

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal string

新值

fn function

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


setTextBackgroundColor(id, newVal, fn)

设置标注文本的背景颜色

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal Color

新颜色值,支持四种格式,取值示例

fn function

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


setTextOffset(id, newVal, fn)

设置文本偏移

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

新值

fn function

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


setTextRange(id, newVal, fn)

设置文本可视范围: [近裁距离, 远裁距离]

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal array

新值

fn function

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


setURL(id, newVal, fn)

设置标注的URL

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal string

新值,资源引入说明

fn function

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


setUserData(id, newVal, fn)

设置用户数据

Parameters:
Name Type Description
id string

标注的唯一标识符ID

newVal string

新值

fn function

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


show(ids, fn)

显示标注

Parameters:
Name Type Description
ids string | array

标注对象的ID或者ID数组

fn function

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


showAll(fn)

显示所有标注

Parameters:
Name Type Description
fn function

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


showAllPopupWindow(fn)

显示所有标注的弹出窗口

Parameters:
Name Type Description
fn function

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


showByGroupId(groupId, fn)

根据分组ID显示Marker

Parameters:
Name Type Description
groupId string

Marker创建时指定的分组ID

fn function

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


showPopupWindow(ids, fn)

显示指定标注的弹出窗口

Parameters:
Name Type Description
ids string | array

标注对象的ID或者ID数组

fn function

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


update(data, fn)

修改一个或多个标注对象

Parameters:
Name Type Description
data data | array

标注点的数据,参考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: