# new M3DModelCacheLayer(options)
M3D缓存图层
参数:
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
options |
Object | 构造参数 |
|
elevationInfo |
ElevationInfo | 高程模式。目前仅支持栅格体元设置高程模式,且如果设置featureExpressionInfo ,则必须按照$feature.z的方式索引高程值,且目前仅支持简单的表达式,例如可以设置将每个高程值替换为原来的10倍,可以设置表达式'$feature.z * 10' |
|
timeExtent |
TimeExtent | 时间范围,具有明确开始和结束日期的一段时间。时间范围用于显示或查询指定时间段内的要素。要表示某个时刻,需要将开始时间和结束时间设置为同一日期。 |
|
clientFilters |
Array.<VoxelFilter> | [] | 客户端过滤器,当前仅支持数据的第一个VoxelFilter过滤器。 |
url |
String | 服务基地址,支持文件服务和IGS的M3D服务 |
|
renderer |
BaseRenderer | 渲染器, |
支持如下方法:
[1、加载图层资源][2、通过传入的json构造并返回一个新的图层对象]
[3、导出为json对象]
[4、克隆图层对象]
[5、通过url构造图层对象]
示例
// ES5引入方式
const { M3DModelCacheLayer } = zondy.layer
// ES6引入方式
import { M3DModelCacheLayer } from "@mapgis/webclient-common"
const layer = new M3DModelCacheLayer({
// 服务基地址
url: '服务基地址'
// Cesium引擎的额外初始化参数
extensionOptions: {
// 开启自动跳转
autoReset: true
}
});
// ES5引入方式
const { M3DModelCacheLayer } = zondy.layer
const { UniqueValueRenderer } = zondy.renderer
const { SimpleFillSymbol,SimpleLineSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { M3DModelCacheLayer,UniqueValueRenderer,SimpleFillSymbol,SimpleLineSymbol,Color } from "@mapgis/webclient-common"
// 构造单值渲染器
const renderer = new UniqueValueRenderer({
// 专题图过滤字段名
field: "字段名",
// 单值专题图过滤条件数组
uniqueValueInfos: [
{
// 指定字段值
value: '过滤字段值1',
// 匹配到该值后的样式
// M3D专题图仅支持SimpleFillSymbol符号
symbol: new SimpleFillSymbol({
// 填充颜色
color: new Color(255, 0, 0)
})
},
{
// 指定字段值
value: '过滤字段值2',
// 匹配到该值后的样式
// M3D专题图仅支持SimpleFillSymbol符号
symbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgb(255, 123, 220)'
})
}
]
})
// 构造模型缓存图层
const layer = new M3DModelCacheLayer({
// 服务基地址
url: '服务基地址',
// 设置专题图渲染器
renderer: renderer,
// Cesium引擎的额外初始化参数
extensionOptions: {
// 开启自动跳转
autoReset: true
}
});
// ES5引入方式
const { M3DModelCacheLayer } = zondy.layer
const { ClassBreakRenderer } = zondy.renderer
const { SimpleFillSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { M3DModelCacheLayer,ClassBreakRenderer,SimpleFillSymbol,Color } from "@mapgis/webclient-common"
// 构造分段渲染器
const renderer = new ClassBreakRenderer({
// 专题图过滤字段名
field: "字段名",
// 分段专题图过滤条件数组
classBreakInfos: [
{
// 最小过滤范围,field对应的值大于等于minValue
minValue: 0,
// 最大过滤范围,field对应的值小于maxValue
maxValue: 2,
// 匹配到该值后的样式
// M3D专题图仅支持SimpleFillSymbol符号
symbol: new SimpleFillSymbol({
// 填充颜色
color: new Color(255, 0, 0)
})
},
{
// 最小过滤范围,field对应的值大于等于minValue
minValue: 3,
// 最大过滤范围,field对应的值小于maxValue
maxValue: 5,
// 匹配到该值后的样式
// M3D专题图仅支持SimpleFillSymbol符号
symbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgb(255, 123, 220)'
})
}
]
})
// 构造模型缓存图层
const layer = new M3DModelCacheLayer({
// 服务基地址
url: '服务基地址',
// 设置专题图渲染器
renderer: renderer,
// Cesium引擎的额外初始化参数
extensionOptions: {
// 开启自动跳转
autoReset: true
}
});
// ES5引入方式
const { M3DModelCacheLayer } = zondy.layer
// ES6引入方式
import { M3DModelCacheLayer } from "@mapgis/webclient-common"
// 构造Cesium原生渲染器
const renderer = {
// 专题图过滤字段名
field: "字段名",
// 专题图类型-分段
type: "class-breaks",
// 分段专题图过滤条件数组
classBreakInfos: [{
// 最小过滤范围,field对应的值大于等于minValue
minValue: 1,
// 最大过滤范围,field对应的值小于maxValue
maxValue: 7,
// 渲染符号
symbol: {
// 渲染类型为M3D
type: 'mesh-3d',
// 覆盖物图层
symbolLayers: [{
// 图层类型-颜色填充
type: "fill",
// 图层材质
material: {
// 填充颜色
color: Cesium.Color.ANTIQUEWHITE
}
}]
}
}]
}
// 构造模型缓存图层
const layer = new M3DModelCacheLayer({
// 服务基地址
url: '服务基地址',
// Cesium引擎的额外初始化参数
extensionOptions: {
// 开启自动跳转
autoReset: true,
// 设置专题图渲染器
renderer: renderer
}
});
// ES5引入方式
const { M3DModelCacheLayer } = zondy.layer
// ES6引入方式
import { M3DModelCacheLayer } from "@mapgis/webclient-common"
// 构造Cesium原生渲染器
const renderer = {
// 专题图过滤字段名
field: "字段名",
// 专题图类型-单值
type: "unique-value",
// 单值专题图过滤条件数组
uniqueValueInfos: [
// 指定字段值
value: '过滤字段值',
// 渲染符号
symbol: {
// 渲染类型为M3D
type: 'mesh-3d',
// 覆盖物图层
symbolLayers: [{
// 图层类型-颜色填充
type: "fill",
// 图层材质
material: {
// 填充颜色
color: new Cesium.Color(0.0, 0.0, 1.0, 0.5)
}
}]
}
]
};
// 构造模型缓存图层
const layer = new M3DModelCacheLayer({
// 服务基地址
url: '服务基地址',
// Cesium引擎的额外初始化参数
extensionOptions: {
// 开启自动跳转
autoReset: true,
// 设置专题图渲染器
renderer: renderer
}
});
继承关系
成员变量
# elevationInfo
高程模式。目前仅支持栅格体元设置高程模式,且如果设置featureExpressionInfo ,则必须按照$feature.z的方式索引高程值,且目前仅支持简单的表达式,例如可以设置将每个高程值替换为原来的10倍,可以设置表达式'$feature.z * 10'
# maxScale
最大显示比例尺,图层在视图中可见的最大比例尺(最放大)。如果地图被放大到超过这个比例,图层将不可见。默认值为0,0表示图层没有最大比例尺、可见性不受最大比例尺限制。maxScale应该始终小于minScale。
- Inherited From:
- Default Value:
- 0
# minScale
最小显示比例尺,图层在视图中可见的最小比例尺(最缩小)。如果地图被缩小到超过这个比例,图层将不可见。默认值为0,0表示图层没有最小比例尺、可见性不受最小比例尺限制。minScale应该始终大于maxScale。
- Inherited From:
- Default Value:
- 0
# opacity
图层透明度,0到1之间的值,0为完全透明,1为不透明,会触发图层更新完毕事件。IGSSceneLayer图层类型为地形时,不支持该属性。
- Inherited From:
方法
# load()
加载图层资源
示例
// ES5引入方式
const { M3DModelCacheLayer } = zondy.layer
// ES6引入方式
import { M3DModelCacheLayer } from "@mapgis/webclient-common"
// 初始化图层
const layer = new M3DModelCacheLayer({
// 服务基地址
url: '服务基地址',
});
layer.load().then((result) => {
// 获取完图层信息
console.log(result)
})
事件
# 图层刷新完毕事件
图层刷新完毕事件,请注意该事件是图层更新事件(layerview-update)的子事件
属性:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | 事件对象 |
||
type |
String |
<optional> |
'layerview-update' | 图层更新完毕事件 |
message |
String |
<optional> |
null | 更新描述 |
updateContent |
Array.<UpdateContent> |
<optional> |
null | 更新详情对象 |
layer |
Layer |
<optional> |
null | 地图图层对象 |
layerView |
MapView |
<optional> |
null | 图层的视图对象 |
sourceTarget |
Layer |
<optional> |
null | 事件发起对象 |
target |
Map |
<optional> |
null | 事件接收对象 |
- Inherited From:
示例
图层刷新完毕事件
Layer.on('layerview-update', function (event) {
// 获取更新事件对象
console.log("更新完毕:", event)
// 获取更新详情数组
const updateContent = event.updateContent
// 循环数组,根据事件名进行后续操作
for (let i = 0; i < updateContent.length; i++) {
// 图层刷新完毕事件
if(updateContent[i].name === 'refresh'){
console.log("图层刷新完毕事件:", event);
}
}
});
# 图层加载完毕事件
图层加载完毕事件
属性:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | 事件对象 |
||
type |
String |
<optional> |
'layerview-created' | 图层加载完毕事件 |
message |
String |
<optional> |
null | 更新描述 |
UpdateContent |
Array.<UpdateContent> |
<optional> |
null | 更新详情对象 |
layer |
Layer |
<optional> |
null | 地图图层对象 |
layerView |
MapView |
<optional> |
null | 图层的视图对象 |
sourceTarget |
Layer |
<optional> |
null | 事件发起对象 |
target |
Map |
<optional> |
null | 事件接收对象 |
- Inherited From:
示例
Layer.on('layerview-created', function (result) {
console.log("加载完毕:", result.layer)
});
# 图层显隐更新完毕事件
图层显隐更新完毕事件,请注意该事件是图层更新事件(layerview-update)的子事件
属性:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | 事件对象 |
||
type |
String |
<optional> |
'layerview-update' | 图层更新完毕事件 |
message |
String |
<optional> |
null | 更新描述 |
updateContent |
Array.<UpdateContent> |
<optional> |
null | 更新详情对象 |
layer |
Layer |
<optional> |
null | 地图图层对象 |
layerView |
MapView |
<optional> |
null | 图层的视图对象 |
sourceTarget |
Layer |
<optional> |
null | 事件发起对象 |
target |
Map |
<optional> |
null | 事件接收对象 |
- Inherited From:
示例
图层显隐更新完毕事件
Layer.on('layerview-update', function (event) {
// 获取更新事件对象
console.log("更新完毕:", event)
// 获取更新详情数组
const updateContent = event.updateContent
// 循环数组,根据事件名进行后续操作
for (let i = 0; i < updateContent.length; i++) {
// 图层显隐事件
if(updateContent[i].name === 'visible'){
console.log("图层显隐更新事件:", event);
}
}
});
# 图层更新完毕事件
图层更新完毕事件
属性:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | 事件对象 |
||
type |
String |
<optional> |
'layerview-update' | 图层更新完毕事件 |
message |
String |
<optional> |
null | 更新描述 |
updateContent |
Array.<UpdateContent> |
<optional> |
null | 更新详情对象 |
layer |
Layer |
<optional> |
null | 地图图层对象 |
layerView |
MapView |
<optional> |
null | 图层的视图对象 |
sourceTarget |
Layer |
<optional> |
null | 事件发起对象 |
target |
Map |
<optional> |
null | 事件接收对象 |
- Inherited From:
示例
Layer.on('layerview-update', function (result) {
console.log("更新完毕:", result.layer)
});
# 图层透明度更新完毕事件
图层透明度更新完毕事件,请注意该事件是图层更新事件(layerview-update)的子事件
属性:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | 事件对象 |
||
type |
String |
<optional> |
'layerview-update' | 图层更新完毕事件 |
message |
String |
<optional> |
null | 更新描述 |
updateContent |
Array.<UpdateContent> |
<optional> |
null | 更新详情对象 |
layer |
Layer |
<optional> |
null | 地图图层对象 |
layerView |
MapView |
<optional> |
null | 图层的视图对象 |
sourceTarget |
Layer |
<optional> |
null | 事件发起对象 |
target |
Map |
<optional> |
null | 事件接收对象 |
- Inherited From:
示例
图层透明度更新完毕事件
Layer.on('layerview-update', function (event) {
// 获取更新事件对象
console.log("更新完毕:", event)
// 获取更新详情数组
const updateContent = event.updateContent
// 循环数组,根据事件名进行后续操作
for (let i = 0; i < updateContent.length; i++) {
// 图层透明度更新事件
if(updateContent[i].name === 'opacity'){
console.log("图层透明度更新事件:", event);
}
}
});
# 图层销毁完毕事件
图层销毁完毕事件
属性:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | 事件对象 |
||
type |
String |
<optional> |
'layerview-remove' | 图层销毁完毕事件 |
message |
String |
<optional> |
null | 更新描述 |
updateContent |
Array.<UpdateContent> |
<optional> |
null | 更新详情对象 |
layer |
Layer |
<optional> |
null | 要销毁的地图图层对象 |
layerView |
MapView |
<optional> |
null | 图层的视图对象 |
sourceTarget |
Layer |
<optional> |
null | 事件发起对象 |
target |
Map |
<optional> |
null | 事件接收对象 |
- Inherited From:
示例
Layer.on('layerview-remove', function (result) {
console.log("销毁完毕:", result.layer)
});
# 图层顺序更新完毕事件
图层顺序更新完毕事件,请注意该事件是图层更新事件(layerview-update)的子事件
属性:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | 事件对象 |
||
type |
String |
<optional> |
'layerview-update' | 图层更新完毕事件 |
message |
String |
<optional> |
null | 更新描述 |
updateContent |
Array.<UpdateContent> |
<optional> |
null | 更新详情对象 |
layer |
Layer |
<optional> |
null | 地图图层对象 |
layerView |
MapView |
<optional> |
null | 图层的视图对象 |
sourceTarget |
Layer |
<optional> |
null | 事件发起对象 |
target |
Map |
<optional> |
null | 事件接收对象 |
- Inherited From:
示例
图层顺序更新完毕事件
Layer.on('layerview-update', function (event) {
// 获取更新事件对象
console.log("更新完毕:", event)
// 获取更新详情数组
const updateContent = event.updateContent
// 循环数组,根据事件名进行后续操作
for (let i = 0; i < updateContent.length; i++) {
// 图层顺序更新完毕事件
if(updateContent[i].name === 'index'){
console.log("图层顺序更新完毕事件:", event);
}
}
});