unicore-sdk
v1.5.1
Published
A funtional encapsulation package for 3H GIS+BIM applications.
Downloads
22
Readme
使用手册
使用NPM命令获取unicore:
npm install unicore-sdk
以Vue2.0框架为例,搭建框架后,在vue.config.js添加如下配置:
const { defineConfig } = require('@vue/cli-service')
const path = require("path")
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
const CopyWebpackPlugin = require("copy-webpack-plugin")
const cesiumSource = 'node_modules/cesium/Source';
const cesiumWorkers = '../Build/Cesium/Workers';
module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: {
plugins: [new NodePolyfillPlugin()],
resolve: {
fallback: {
"url": false,
"http": false,
"https": false,
"zlib": false
}
},
plugins: [
// Copy Cesium Assets, Widgets, and Workers to a static directory
new CopyWebpackPlugin({
patterns: [
{ from: path.join(cesiumSource, cesiumWorkers), to: 'Workers' },
{ from: path.join(cesiumSource, 'Assets'), to: 'Assets' },
{ from: path.join(cesiumSource, 'Widgets'), to: 'Widgets' },
{ from: path.join(cesiumSource, 'ThirdParty'), to: 'ThirdParty' }
]
}),
],
module: {
unknownContextRegExp: /^('|')\.\/.*?\1$/,
unknownContextCritical: false
}
}
})
在Vue入口文件引入UniCore SDK及UniCore配置文件、样式文件:
import { UniCore } from 'unicore-sdk'
import { config } from 'unicore-sdk/unicore.config'
import 'unicore-sdk/Widgets/widgets.css'
在初始化方法调用(accessToken可联系开发者获取Token获取方法):
测试Token:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJhZjNjZjBlNC03NmFiLTQ2YjgtYmZhZC0wY2QwY2IxNmUxYWMiLCJpZCI6MTc1NzkyLCJpYXQiOjE3MDQ0MzU4OTB9.wphDRUr7J7LRUHRxsYaPk7mbz-0Ct9czww9lsbRGi_E
// 初始化unicore
let uniCore = new UniCore(config, accessToken);
uniCore.init("unicoreContainer");
let viewer = window.viewer;
在前端界面新增一段用于存放显示区域的div(通过css样式修改可以将显示区域调整为全屏,这里展示未作修改的样式):
<div id="unicoreContainer"></div>
运行命令npm run serve,即可看到UniCore SDK已初始化完毕。关于SDK相关开发文档稍后整理。