Constructor
new ViewerEx(viewer, config)
Parameters:
Name | Type | Description |
---|---|---|
viewer |
Cesium.Viewer | |
config |
object |
Classes
Methods
addOperationalLayer(layer) → {boolean}
把通过 zz3d.layer.createLayer 函数创建出来的图层添加到viewer中,进行集中控制
添加到viewer.zz.config.operationallayers
Parameters:
Name | Type | Description |
---|---|---|
layer |
BaseLayer | 要添加的layer |
Returns:
是否成功
- Type
- boolean
backOperateMode()
还原操作模式
cancelCenterAt()
取消飞行
cancelPanMode()
退出平移模式
cancelRotateMode()
退出旋转模式
centerAt(centeropt, options)
地球定位至指定区域
Parameters:
Name | Type | Description |
---|---|---|
centeropt |
Object | 目标点 支持以下几种形式 |
options |
Object | 支持viewer.camera.flyTo所有参数 |
centerAtArr(arr, enfun)
定位到 多个区域 顺序播放
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | 一系列目标点 |
enfun |
function | 结束回调 |
centerAtByBoundingSphere(centeropt, options)
按照包围球的方式定位至指定区域 最终调用的是camera.flyToBoundingSphere接口
当定位区域范围时 会使用区域范围构建包围球,包围球中心点为目标点,包围球半径*radius作为距目标点距离 此时radius默认值取1,为距离系数
当定位单点时,radius表示相机到该点的距离 默认值100
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
centeropt |
Cartesian3 | Object | 目标点 支持以下几种形式 |
||||||||||||||||||||
options |
Object | 支持viewer.camera.flyToBoundingSphere所有参数 Properties
|
centerAtHome(options)
定位home位置
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | 支持viewer.camera.flyTo所有参数 |
centerAtLayer(图层id)
图层定位
Parameters:
Name | Type | Description |
---|---|---|
图层id |
String |
centerPoint(centeropt, options)
定位至目标点
Parameters:
Name | Type | Description |
---|---|---|
centeropt |
Object | Cartesian3 | 目标点 eg:{x:xxx,y:xxx,z:xxx}经纬高 |
options |
Object | 支持viewer.camera.flyToBoundingSphere所有参数 |
changeLayerShowModel(图层id, model, height)
修改图层显示模式
Parameters:
Name | Type | Description |
---|---|---|
图层id |
String | |
model |
Number | 1 二维模式 2矢量贴地 3矢量抬高 |
height |
Number | 高度 |
clearlimitHeightEffect()
清除限高分析效果
Returns:
None
createFanshapedEntity(opts) → {Array}
创建扇形或扇形体 创建完成会自动添加到场景 返回实体数组
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opts |
单个option或者一组option option会用来创建Polygon 支持所有Cesium原生属性 |
||
options.longitude |
Number |
<optional> |
扇形圆心经度坐标 |
options.latitude |
Number |
<optional> |
扇形圆心纬度坐标 |
options.height |
Number |
<optional> |
扇形圆心高度 |
options.radius |
Number |
<optional> |
扇形半径 |
options.startAngle |
Number |
<optional> |
扇形起始角 |
options.endAngle |
Number |
<optional> |
扇形终止角 |
Returns:
创建的扇形体数组
- Type
- Array
createOrModifyDirectionLightSource(idopt, typeopt, diropt, tilesetArrayopt, strengthopt)
创建平行光
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
Number |
<optional> |
光源id |
|
type |
Number |
<optional> |
光源类型 0水平 1垂直 |
|
dir |
Cesium.Cartesian3 |
<optional> |
光照方向 |
|
tilesetArray |
Array |
<optional> |
受影响的图层tileset |
|
strength |
Number |
<optional> |
1
|
光源强度 |
createOrModifyPointLightSource(idopt, posopt, tilesetArrayopt, picURLopt, distanceopt, decayopt, strengthopt)
创建或修改点光源
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
Number |
<optional> |
光源id |
|
pos |
Cesium.Cartesian3 |
<optional> |
点光源位置 |
|
tilesetArray |
Array |
<optional> |
受影响的图层tileset |
|
picURL |
String |
<optional> |
光源处绘制的billboard图片 |
|
distance |
Number |
<optional> |
1000
|
扩散距离 |
decay |
Number |
<optional> |
1
|
衰减因子 |
strength |
Number |
<optional> |
1
|
光源强度 |
createOrModifySpotLightSource(idopt, posopt, tilesetArrayopt, picURLopt, distanceopt, decayopt, strengthopt)
创建聚光灯
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
Number |
<optional> |
光源id |
|
pos |
Cesium.Cartesian3 |
<optional> |
光源位置 |
|
tilesetArray |
Array |
<optional> |
受影响的图层tileset |
|
picURL |
String |
<optional> |
光源处绘制的billboard图片 |
|
distance |
Number |
<optional> |
200
|
扩散距离 |
decay |
Number |
<optional> |
0.5
|
衰减因子 |
strength |
Number |
<optional> |
5
|
光源强度 |
deleteAllLightSource()
删除所有光源
deleteLightSourceByID(idopt)
根据ID删除光源
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
Number |
<optional> |
光源id |
destroy()
销毁资源
drillPick(x, y, widthopt, heightopt, cbFunc) → {Array}
多重pick 会返回目标点位置上交到的所有图层的求交信息
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
Number | 窗口坐标X |
||
y |
Number | 窗口坐标Y |
||
width |
Number |
<optional> |
3
|
拓展的求交范围 求交并不是用一个点去计算 而是用一个小方框去计算 |
height |
Number |
<optional> |
3
|
拓展的求交范围 |
cbFunc |
function | 求交完成后执行的回调函数,参数为求交结果数组 |
Returns:
resArray 求交结果 从上到下排序
- Type
- Array
enableLimitHeightEffect(ptArray, baseHeight, limitHeight, color)
执行限高分析
Parameters:
Name | Type | Description |
---|---|---|
ptArray |
Array | 轮廓点组 Cartesian3类型 |
baseHeight |
Number | 基准面高度 相对地表 |
limitHeight |
Number | 限制高度 相对基准面 |
color |
Array | 皮筋儿颜色 rgba数组 范围0~1 比如[1,0,0,0.5] |
Returns:
None
enterPanMode()
进入平移模式 即鼠标只能执行平移操作
enterRotateMode()
进入旋转模式
expImage(opts)
导出场景图片 截面
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object | 含有以下属性的对象: Properties
|
exportImageByRtt(opts)
导出场景图片
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object | 含有以下属性的对象: Properties
|
flyTo(entity, options)
视角飞行定位到entiy处
若entity是billboard/point/label/model/ellipse 则最终调用的是centerPoint接口来定位中心点 opts按centerPoint对应参数来设置
若entity是数组 则根据所有entity确定的范围来调用centerAt接口 opts按centerAt对应参数来设置
若entity确定的范围经纬度跨度超越了180度 则执行的是viewer.flyTo接口 opts支持viewer.flyTo所有参数
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | Array | 目标点 |
options |
Object | 视角相关设置参数 |
flyToByBoundingSphere(entity, options)
视角飞行定位到entiy处 此接口会使用entity获取的点或点组构建包围球,然后进行定位操作
本质上调用的是centerAtByBoundingSphere接口,因此opts支持centerAtByBoundingSphere接口的相应参数
若entity确定的范围经纬度跨度超越了180度 则执行的是viewer.flyTo接口 opts支持viewer.flyTo所有参数
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
entity |
Entity | Array | 目标实体或实体数组 |
||||||||||||||||||||
options |
Object | 视角相关设置参数 Properties
|
getCameraPos() → {Array}
获取当前场景相机位置
Returns:
resArray 存储相机位置参数的数组 该数组可作为参数直接传入setCameraPos接口
- Type
- Array
getConfig() → {Object}
获取配置信息
Returns:
- Type
- Object
getCrs() → {String}
获取当前地图坐标系,值为gcj时表示是国测局偏移坐标
Returns:
- Type
- String
getLayer(key, keyname) → {Object|Array.<Object>}
获取指定图层 keyname默认为名称
Parameters:
Name | Type | Description |
---|---|---|
key |
Number | String | 可以是字符或数字 |
keyname |
String | key对应的字段名称 默认情况下若key是Num则认为是id,若key是string则认为是name |
Returns:
得到的图层,一个或者多个
- Type
- Object | Array.<Object>
getLayerConfig(id) → {Object}
根据id得到图层配置信息
Parameters:
Name | Type | Description |
---|---|---|
id |
String | Number |
Returns:
config 图层的配置
- Type
- Object
getLegendImages(param) → {Promise}
获取所有显示图层的图例
Parameters:
Name | Type | Description |
---|---|---|
param |
Object | GETLEGENDIMAGELIST后端接口覆盖参数主要用具控制图片大小 |
Returns:
- Type
- Promise
getNextId() → {Number}
生成一个有效的图层ID
Returns:
- Type
- Number
(async) initLayers()
初始化config中的 operationallayers 图层
Returns:
Promise
isFlyAnimation() → {Boolean}
是否在调用了openFlyAnimation正在进行飞行动画
Returns:
- Type
- Boolean
keyboard(isbind, opts)
键盘漫游
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
isbind |
Boolean | 是否绑定按键操作 |
|||||||||||||||||||||||||||||||||||
opts |
Object | 含有以下属性的对象: Properties
|
locateByPtArray(ptArray, options)
用ptArray中的点组进行定位操作
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ptArray |
Array | 点组 点类型Cart3 |
||||||||||||||||||||||||||||||
options |
Object | 视角相关设置参数 Properties
|
openFlyAnimation(endfun, centeropt)
开场动画,动画播放地球飞行定位指指定区域(默认为config.josn中配置的视域)
Parameters:
Name | Type | Description |
---|---|---|
endfun |
function | 动画播放完成后执行的回调函数 |
centeropt |
Object | 飞行目标点 |
removeOperationalLayer(id)
根据ID来移除图层
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | String | 图层ID |
resetLimitHeight(h)
重置限制高度
Parameters:
Name | Type | Description |
---|---|---|
h |
Number | 限制高度 相对基准面 |
Returns:
None
rotateAnimation(endfun, duration)
旋转地球
Parameters:
Name | Type | Description |
---|---|---|
endfun |
function | 完成回调 |
duration |
Number | 持续时间 |
setCameraPos(posArray, durationopt)
设置当前场景相机位置
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
posArray |
Array | 存储相机位置参数的数组 从getCameraPos中获取或者由相机的pos/dir/up组成,长度为9 若为二维数组,则可逐个进行飞行定位 |
||
duration |
Number |
<optional> |
3
|
相机飞行到下个位置所花费的时间 单位是秒 |
setEnablePicking(enable)
设置场景是否允许单击pick
Parameters:
Name | Type | Description |
---|---|---|
enable |
Boolean | 是否允许单击pick |
setLayerOpacity(图层id, opacity)
修改图层 透明度
Parameters:
Name | Type | Description |
---|---|---|
图层id |
String | |
opacity |
Number | 透明度 0-1 |
setLayerVisible(id, visible)
修改图层visible
Parameters:
Name | Type | Description |
---|---|---|
id |
String | 图层id |
visible |
Boolean | 显示还是隐藏 true / false |
setLocationComputeCallback(cb)
设置自定义计算location显示值的回调函数
Parameters:
Name | Type | Description |
---|---|---|
cb |
function |
setOperateMode(num)
设置操作模式
Parameters:
Name | Type | Description |
---|---|---|
num |
Number | 三位二进制数字 abc c权重为1 表示是否允许平移 b权重为2 表示是否允许旋转 c权重为4 表示是否允许缩放 |
trackerEntity(ent, viewFromopt)
跟踪实体
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ent |
Entity | 要跟踪的实体 传入undefined时取消跟踪 |
|
viewFrom |
Cartesian3 |
<optional> |
跟踪时距离实体的方位距离 x表示实体前进方向 y表示实体的侧面 X的垂直方向 z表示实体上方 |