chbim-plugins
v0.0.107
Published
一个简单的组件库
Downloads
1,241
Readme
使用指南
- 此插件和 CHBIM 平台强绑定
- node 版本>=16.14.2
安装
npm i chbim-plugins
引入
import "chbim-plugins/style.css";
import { ChbimPlugins } from "chbim-plugins";
......
......
......
app.use(ChbimPlugins);
使用
在需要使用的.vue 文件里面引入
import {
BimTerrainProvider, // 地形
BimElevationImage, // 瓦片
BimModel, // 模型
BimVector, // 矢量
BimEntity, // 注记
PanoramicView, // 全景图
......
} from "chbim-plugins";
添加模型为例:
/* data 为模型树的扁平化json */
window.bimModel = new BimModel(data);
/* 给地图添加模型
** id => 模型id
** fn => 自定义注册事件
*/
window.bimModel.add(id,fn).then((e) => {
if (e.type == "error") {
console.error('失败')
}
}).catch((e) => {
console.error('失败')
})
API
window.bimElevationImage 影像
add( id || xyzParameter,isGisTkone,fn)添加影像
| 类参数名 | 类型 | 默认参数 | 描述 |
| ------------ | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| id | String | “ ” | 需要添加的影像 id |
| xyzParameter | Object | { } | 三方影像数据 {imageXyzId:影像id,url:影像路由,zIndex:影像层级,minimumLevel:服务支持的最小层级,maximumLevel:服务支持的最大层级,chinaCRS:标识瓦片的国内坐标系(用于自动纠偏或加偏)}
chinaCRS 默认 GCJ02 |
| isGisTkone | Boolean | true | 是否开启 Tkone 验证,三方影像不需要开启验证 |
| fn | Object | { } | 例如:绑定 click 事件 { click: (e) => { console.log(e) } }
|
remove( id )添加影像
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | ----------------- | | id | String | “ ” | 需要移除的影像 id |
query( id )查询影像的数据
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | ------------------------------- | | id | String | “ ” | 需要查询的模型 id,返回模型数据 |
window.bimModel 模型
add( id,fn,list )添加模型
| 类参数名 | 类型 | 默认参数 | 描述 |
| -------- | ------ | -------- | ------------------------------------------------------------ |
| id | String | “ ” | 需要添加的模型 id |
| fn | Object | { } | 例如:绑定 click 事件 { click: (e) => { console.log(e) } }
|
| list | Object | { } | 字段目前用于处理分屏数据 { isClone:true }
|
remove( id,list )移除模型
| 类参数名 | 类型 | 默认参数 | 描述 |
| -------- | ------ | -------- | ------------------------------------------- |
| id | String | “ ” | 需要移除的模型 id |
| list | Object | { } | 字段目前用于处理分屏数据 { isClone:true }
|
selected( id )选中模型
| 类参数名 | 类型 | 默认参数 | 描述 |
| -------- | ------- | -------- | ------------------------------------------------------------ |
| id | String | “ ” | 需要选中的模型 id |
| fn | Object | { } | 例如:绑定 click 事件 { click: (e) => { console.log(e) } }
|
| list | Object | { } | 字段目前用于处理分屏数据 { isClone:true }
|
| flyTo | Boolean | true | 默认会自动飞行,模型选中变红,设置false
不会飞行 |
query( id )查询模型的数据
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | ------------------------------- | | id | String | “ ” | 需要查询的模型 id,返回模型数据 |
queryModel( id )查询 map 上模型的实体
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | ------------------------------- | | id | String | “ ” | 需要查询的模型 id,返回模型实体 |
editColor( id,newColor,list )模型染色
| 类参数名 | 类型 | 默认参数 | 描述 |
| -------- | ------ | -------- | ------------------------------------------- |
| id | String | “ ” | 模型 id |
| newColor | String | “ ” | css 颜色值 |
| list | Object | { } | 字段目前用于处理分屏数据 { isClone:true }
|
editOpacity( id,opacity)模型染色
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | ------------ | | id | String | “ ” | 模型 id | | opacity | String | “ ” | 透明度值 0~1 |
window.bimVector 矢量
add( id,list )添加矢量
| 类参数名 | 类型 | 默认参数 | 描述 |
| -------- | ------ | -------- | ------------------------------------------- |
| id | Object | “ ” | 需要添加的矢量 id |
| list | Object | { } | 字段目前用于处理分屏数据 { isClone:true }
|
remove( id,list )移除矢量
| 类参数名 | 类型 | 默认参数 | 描述 |
| -------- | ------ | -------- | ------------------------------------------- |
| id | String | “ ” | 需要移除的矢量 id |
| list | Object | { } | 字段目前用于处理分屏数据 { isClone:true }
|
selected( id )添加矢量
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | ------------------------------------------ | | id | Object | “ ” | 需要选中的矢量 id ,选中会飞行到选中的矢量 |
query( id )添加矢量
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | -------------------------------- | | id | Object | “ ” | 需要选中的矢量 id ,返回矢量数据 |
queryVector( id )添加矢量
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | -------------------------------- | | id | Object | “ ” | 需要选中的矢量 id ,返回矢量实体 |
window.bimEntity 标绘
add( id,entityId,list )添加标绘
| 类参数名 | 类型 | 默认参数 | 描述 |
| -------- | ------ | -------- | ----------------------------------------------- |
| id | Object | “ ” | 需要添加的标绘 id |
| entityId | String | null | 临时添加的标绘是不带 id 的,需要自定义的一个 id |
| list | Object | { } | 字段目前用于处理分屏数据 { isClone:true }
|
remove( id,list )移除标绘
| 类参数名 | 类型 | 默认参数 | 描述 |
| -------- | ------ | -------- | ------------------------------------------- |
| id | String | “ ” | 需要移除的标绘 id |
| list | Object | { } | 字段目前用于处理分屏数据 { isClone:true }
|
query( id )添加标绘
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | -------------------------------- | | id | Object | “ ” | 需要选中的矢量 id ,返回矢量数据 |
queryEntity( id )添加标绘
| 类参数名 | 类型 | 默认参数 | 描述 | | -------- | ------ | -------- | -------------------------------- | | id | Object | “ ” | 需要选中的矢量 id ,返回矢量实体 |
版本控制
该项目使用 Git 进行版本管理。