类名 VectorTileSubLayer

# new VectorTileSubLayer(options)

矢量瓦片子图层基类

参数:

名称 类型 默认值 描述
options Object

构造参数

id String

矢量瓦片子图层的id

title String

矢量瓦片子图层的标题

visible Boolean true

图层可见性

styleLayers Array.<Object>

矢量瓦片子图层关联的矢量瓦片样式图层数组,只读属性

layer VectorTileLayer

矢量瓦片父图层对象

renderer BaseRenderer

专题图渲染样式对象,支持如下渲染样式:
1、单值渲染
2、分段渲染
3、统一专题图

labelingInfo Array.<LabelClass> []

三维注记参数,仅当igs矢量瓦片图层labelsRenderMode设置非'off-screen'属性时生效。为性能考虑,当前所有子图层labelingInfo内labelClass必须保证renderMode一致,不支持同时设置label或canvas两种形式。

继承关系

成员变量

Object

# extendProps

初始化当前图层对象上不支持的属性,二次开发用户希望挂在图层对像上的属性可以存储到该属性中

Inherited From:
Default Value:
  • {}
Object

# extensionOptions

初始化图层的额外参数,可以通过该参数传入引擎原生的构造参数

Inherited From:
Default Value:
  • {}
String

# id

图层id,不给则生成随机id

Inherited From:
Array.<LabelClass>

# labelingInfo

三维注记参数,仅当igs矢量瓦片图层labelsRenderMode设置非'off-screen'属性时生效。为性能考虑,当前所有子图层labelingInfo内labelClass必须保证renderMode一致,不支持同时设置label或canvas两种形式。

Layer

# layer

父图层对象

Overrides:
UniqueValueRenderer | ClassBreakRenderer | SimpleRenderer

# renderer

矢量瓦片子图层专题图渲染样式

SpatialReference

# spatialReference

子图层空间参考系

Overrides:
Array

# sublayers

包含的子图层对象

Inherited From:
String

# title

图层名称

Inherited From:
String

# readonly type

图层的类型

Array.<Object>

# readonly type

矢量瓦片子图层关联的矢量瓦片样式图层

Boolean

# visible

矢量瓦片子图层是否可见

Overrides:
Default Value:
  • true

方法

# static fromJSON(json)

通过json对象初始化该对象

参数:

名称 类型 描述
json Object

json对象

# clone()

克隆图层对象

Overrides:

克隆后的图层对象

# off(typesopt, fnopt, contextopt)

参数:

名称 类型 描述
types string

移除指定事件类型上绑定的回调函数
当类型为字符串时,可以移除单个或多个事件类型绑定的回调函数,单个事件:"click",多个事件:以空格分割:"click double-click";
当types为对象时,使用如下方式移除事件:{'click': onClickFun, 'mouse-move': onMouseMoveFun}

fn function

事件回调函数,当types为字符串,且不指定要删除的回调函数时,删除该事件上的所有回调函数

context Object

事件回调函数的this关键字将指向的对象

Inherited From:

当前实例

Object
示例

移除一个事件的指定回调函数

// 一个事件的回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
}
// 调用MapView或SceneView的off方法移除一个事件的回调函数
view.off('click', clickFunction)

移除一个事件的所有回调函数

// 一个事件的回调函数1
const clickFunction1 = function (event) {
  console.log("点击事件1:", event)
}

// 一个事件的回调函数2
const clickFunction2 = function (event) {
  console.log("点击事件2:", event)
}

// 调用MapView或SceneView的off方法移除一个事件的所有回调函数
// 不指定回调函数,则移除该事件上的所有绑定的回调函数
view.off('click')

移除多个事件的同一个指定的回调函数

// 多个事件的同一个回调函数
const eventFunction = function (event) {
  console.log("事件:", event)
}
// 调用MapView或SceneView的off方法移除多个事件的同一个指定的回调函数
view.off('click double-click', eventFunction)

移除多个指定事件的回调函数

// 一个事件的回调函数
const clickFunction = function (event) {
  console.log("click事件:", event)
}
// 调用MapView或SceneView的off方法移除多个指定事件的回调函数
view.off({
   // 移除click事件上一个指定的函数
  "click": clickFunction,
  // 移除double-click上所有指定的函数
  "double-click": undefined
})

删除时指定上下文 - types类型为字符串

// 一个事件的回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
}
// 调用MapView或SceneView的off方法移除一个事件的回调函数
view.off('click', clickFunction, view)
// 调用MapView或SceneView的off方法移除一个事件的所有回调函数
view.off('click', undefined, view)

删除时指定上下文 - types类型为对象

// 一个事件的回调函数
const clickFunction = function (event) {
  console.log("click事件:", event)
}
// 调用MapView或SceneView的off方法移除多个指定事件的回调函数
view.off({
   // 移除click事件上一个指定的函数
  "click": clickFunction,
  // 移除double-click上所有指定的函数
  "double-click": undefined
}, view)

# on(typesopt, fnopt, contextopt)

参数:

名称 类型 默认值 描述
types String | Object null

事件类型
当types为字符串时,可以定义单个或多个事件,单个事件:"click",多个事件:以空格分割:"click double-click";
当types为对象时,使用如下方式指定事件:{'click': onClickFun, 'mouse-move': onMouseMoveFun}

fn function null

事件回调函数

context Object null

事件回调函数的this关键字将指向的对象

Inherited From:

当前实例

Object
示例

注册一个事件

// 初始化一个点击事件回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
}
// 调用MapView或SceneView的on方法注册一个点击事件
view.on('click', clickFunction)

一次注册多个事件 - 同一个回调函数

// 初始化一个事件回调函数
const eventFunction = function (event) {
  console.log("事件:", event)
}

// 调用MapView或SceneView的on方法注册多个事件
// 多个事件类型使用同一个回调函数
view.on('click right-click-down', eventFunction)

一次注册多个事件 - 分别指回调应函数

// 初始化一个左键点击事件回调函数
const clickFunction = function (event) {
  console.log("click事件:", event)
}

// 初始化一个右键按下事件回调函数
const rightClickFunction = function (event) {
  console.log("right-click-down事件:", event)
}

// 调用MapView或SceneView的on方法注册多个事件
// 每一个事件类型,使用单独的回调函数
// 注意使用此种方式,一种类型的事件仅能指定一个回调函数
view.on({
  "click": clickFunction,
  "right-click-down": rightClickFunction
})

指定上下文 - types类型为字符串

// 初始化一个点击事件回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
  console.log("上下文对象:", this)
}
// 调用MapView或SceneView的on方法注册一个点击事件
// 指定view为回调函数的上下文对象
view.on('click', clickFunction, view)

指定上下文 - types类型为对象

// 初始化一个点击事件回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
  console.log("上下文对象:", this)
}
// 调用MapView或SceneView的on方法注册一个点击事件
// 指定view为回调函数的上下文对象
view.on({
  "click": clickFunction,
  "right-click-down": clickFunction
}, view)

# toJSON()

将图层转为json对象

Overrides:

json对象

Object
构造函数
成员变量
方法
事件