LabelLayer

标注图层

new YS.LabelLayer(options, global)

注记(行政区划)图层
Name Type Description
options Object 对象有下面这些属性:
Name Type Default Description
id String optional 唯一标识
name String optional 名称
isAddTree Boolean optional 是否加入树
treeIcon String optional 图层树上显示的图标,默认不显示
minHeight Number optional 最小显示距离
maxHeight Number optional 最大显示距离
fontFamily Font optional 字体
fontSize Number optional 字体大小
color Color optional 字体颜色
haloColor Color #000000 optional 文字描边颜色,使用null将不添加描边
iconUrl String optional 图标url
nameVisible Boolean true optional 图标文字是否可见
visible Boolean optional 是否可见
cluster Boolean false optional 是否对文字进行聚类,聚类后显示最上层文字
autoUpdate Boolean false optional 是否自动更新(加载注记时请设置为true)
global Object 三维球对象(YouScene.earth)
Implements:
Demo:

Members

haloColor : Color

获取或设置描边颜色;如果设置null,将不使用描边;undefined,将使用黑色描边

nameVisible : Boolean

名字是否可见
Default Value: true

visible : Boolean

获取或设置是否可见

Methods

staticYS.LabelLayer.loadServerData(global)

加载服务数据
Name Type Description
global Object 三维球对象(YouScene.earth)

add(label)Label

添加自定义文字到图层
Name Type Description
label Label Label对象
Returns:
label对象

addByJson(jsonData)

添加带文字和图标的点
Name Type Description
jsonData Array.<Object> Json数组
Name Type Description
Name String 文字
Latitude Number 纬度,单位度
Longitude Number 经度,单位度

addLayer(global)

添加图层
Name Type Description
global Object 三维球对象(YouScene.earth)

clear()

清除label

destroy()

销毁
Implements:

getById(id)Feature

根据id获取图层内对象
Name Type Description
id String 对象的id
Returns:
返回查找到的对象,找不到返回undefined
Implements:

getByIdIndex(id)Number

根据id获取图层内对象的索引
Name Type Description
id String 对象的id
Returns:
返回查找到的对象的索引,找不到返回undefined

removeById(id)

根据id移除标注
Name Type Description
id String 对象的id

useCluster(enable)

启用或关闭聚合,关闭可提升性能
Name Type Description
enable Boolean true时启用聚合,false时关闭聚合

Events

click

鼠标点击事件(如果子类Label的click被调用,那么这个事件不会生效)
Implements:

featureAdded

添加标注事件
Name Type Description
labelLayer LabelLayer 触发事件的对象
label Label 被添加的标注对象
Implements:

featureCleared

标注清空事件
Name Type Description
labelLayer LabelLayer 触发事件的对象
Implements:

featureRemoved

删除标注事件
Name Type Description
labelLayer LabelLayer 触发事件的对象
label Label 被添加的标注对象
Implements:

mouseHover

鼠标覆盖事件(如果子类Label的mouseHover被调用,那么这个事件不会生效)
Implements:

mouseOut

鼠标移出事件(如果子类Label的mouseOut被调用,那么这个事件不会生效)
Implements: