1. S3MLayer

Extends: Layer

超图场景以及S3M数据加载模型图层,可实现对超图场景服务和S3MTiles模型的添加、获取、移除、缩放至和显隐等操作,调用前需采用webgl1,即requestWebgl2为 false,如下所示。

var geomap = new BOSGeo.GeoMap('bosgeoContainer', {requestWebgl2: false})

1.1. 初始化 new S3MLayer(options, customGroupId)

Param Type Description
options Object

包含以下参数的Object对象:

options.name String

图层名称;

options.show Boolean

是否显示;

options.customGroupId String

自定义分组的ID。

Example

//通过图层管理类统一创建
        let s3mLayer = layerManager.createLayer(BOSGeo.LayerType.S3M, "S3M模型");

1.2. 属性

属性名 Type Default Description
show Boolean

是否显示图层

selectedColor String

选中时十六进制的颜色字符串

maxVisibleAltitude Number

获取或设置图层的最大可见高度。

minVisibleAltitude Number

获取或设置图层的最小可见高度。

visibleDistanceMax Number

获取或设置该图层的最大可见距离值,单位为米。该距离值用于距离过滤功能,当相机与图层的距离大于该距离值时,该图层将不可见。

visibleDistanceMin Number

获取或设置该图层的最小可见距离值,单位为米。该距离值用于距离过滤功能,当相机与图层的距离小于该距离值时,该图层将不可见。

order Number 0

排序序号

customGroupId String

分组id

models Array.<(Model|Cesium3DTileset)>

该图层的所有模型

1.3. 方法

1.3.1. s3MLayer.add(options) ⇒ Promise

加载iserver场景服务下所有图层

Param Type Default Description
options Object

包含以下参数的Object对象:

[options.id] String

添加的模型场景对象的id值, 默认为GUID值,选填。

[options.byScp] Boolean false

是否通过addS3MTilesLayerByScp加载单个数据,为true时调用viewer.scene.addS3MTilesLayerByScp加载,S3M服务地址options.url为单个数据的服务地址,如"http://www.supermapol.com/realspace/services/3D-suofeiya_church/rest/realspace/datas/Config/config"。 options.byScp为false时调用viewer.scene.open加载,S3M服务地址(options.url)如"http://www.supermapol.com/realspace/services/3D-Olympic/rest/realspace";

options.url String

supermap的S3M服务地址,示例:url: "http://www.supermapol.com/realspace/services/3D-Olympic/rest/realspace";

[options.name] String

名称,不设置则为undefined;

[options.sceneName] String

工作空间中有多个场景,需要指定场景名称;设置为undefined,默认打开第一个;

[options.subdomains] Array

用于子域,例如:['t1','t2'];

[options.autoSetView] Boolean true

是否自动定位到场景。

[options.maximumMemoryUsage] Number -1

切片数据集可以使用的最大内存量(单位:MB),默认值是-1MB;

[options.lodRangeScale] Number 1

获取或设置图层的LOD层级切换距离缩放系数;

[options.attribute] Object

自定义模型场景属性;

Example

let s3mLayer = geomap.layerManager.createLayer(BOSGeo.LayerType.S3M, "S3M场景模型场景"); //模型场景图层
//1、通过场景服务加载
let myModel1;
s3mLayer.add({
    name: '测试模型场景1',
    byScp: false, //通过场景服务加载
    url: "http://www.supermapol.com/realspace/services/3D-Olympic/rest/realspace",
    attribute: {name: '测试模型场景1'}
}).then((resS3M) => {
    myModel1 = resS3M;
    console.log(myModel1.s3mTilesLayers);
});

Example

// 2、通过单图层数据服务加载
let myModel2 = s3mLayer.add({
    name: '测试模型场景2',
    byScp: false, //通过单图层数据服务加载
    url: "http://www.supermapol.com/realspace/services/3D-suofeiya_church/rest/realspace/datas/Config/config",
    attribute: {name: '测试模型场景2'}
}).then((resS3M) => {
    myModel2 = resS3M;
    console.log(myModel2.s3mTilesLayers);
});

1.3.2. S3MLayer.getModelByName(name)

根据名称获取模型场景

Param Type Description
name String

模型场景名称

Example

s3mLayer.getModelByName('测试模型场景2');

1.3.3. s3MLayer.zoomTo(model, callback)

定位到某个模型场景

Param Type Description
model Object

含图层的对象

callback function

定位结束后的回调函数

Example

s3mLayer.zoomTo(myModel)

1.3.4. s3MLayer.zoomToLayer(callback)

缩放至本图层

Param Type Description
callback function

回调函数

Example

s3MLayer.zoomToLayer();

1.3.5. s3MLayer.getAllModels()

获取该图层的所有模型场景

1.3.6. s3MLayer.setModelVisibleByName(name, visible)

设置模型场景显隐

Param Type Description
name String

模型场景名称

visible Boolean

是否显示

Example

s3mLayer.setModelVisibleByName('测试模型场景2', false);

1.3.7. s3MLayer.getModelVisible(name)

获取模型场景的显隐信息

Param Type Description
name String

若不填则返回所有显隐信息

Example

let visible = s3mLayer.getModelVisible('测试模型场景2');

1.3.8. s3MLayer.removeByName(name)

根据对象名称移除模型场景

Param Type Description
name String

模型场景名称

Example

s3mLayer.removeByName('测试模型场景2');

1.3.9. s3MLayer.remove(model)

删除模型场景

Param Type Description
model Object

含图层的对象

Example

s3mLayer.remove(myModel)

1.3.10. s3MLayer.removeAll()

移除该图层所有模型场景

1.3.11. s3MLayer.destroy()

销毁本图层

1.3.12. s3MLayer.on(eventType, callBack)

绑定事件

Param Type Description
eventType String | LayerEventType

图层事件类型

callBack function

回调函数

Example

layer.on(BOSGeo.LayerEventType.ADD, (result) => {
    console.log(result);
});

1.3.13. s3MLayer.fire(eventType, value)

触发事件

Param Type Description
eventType String | LayerEventType

监听事件

value *

触发事件时可传入任意值

1.3.14. s3MLayer.hasOn(eventType, callBack)

判断该函数是否已绑定该事件

Param Type Description
eventType String | LayerEventType

监听事件

callBack function

回调函数

Example

var hasBind = layer.hasOn(BOSGeo.LayerEventType.ADD, callback);

1.3.15. s3MLayer.once(eventType, callBack)

绑定后该函数只执行一次

Param Type Description
eventType String | LayerEventType

监听事件

callBack function

回调函数

1.3.16. s3MLayer.off(eventType, callBack)

取消事件绑定

Param Type Description
eventType String

监听事件

callBack function

回调函数

版权所有@盈嘉互联(北京)科技有限公司 京ICP备15051988号-9 Copyright © 2022 all right reserved,powered by Gitbook该文件修订时间: 2022-07-19 11:34:25

results matching ""

    No results matching ""