| @@ -11,7 +11,9 @@ | |||
| > DC-SDK is a 2D and 3D integrated WebGis application framework based on the secondary development of Cesium. This framework optimizes the usage mode of Cesium and adds some additional functions, aiming to build WebGis applications for developers quickly. | |||
| > [Home Page](http://dc.dvgis.cn) | |||
| ## Home | |||
| > http://dc.dvgis.cn | |||
| ```warningH | |||
| Tips:This SDK is JS+GIS framework package. Developers need to have some front-end technology and GIS related technology | |||
| @@ -33,8 +35,8 @@ Tips:This SDK is JS+GIS framework package. Developers need to have some front- | |||
| `NPM / YARN` | |||
| ```shell | |||
| yarn add @dvgis/dc-sdk | |||
| npm install @dvgis/dc-sdk | |||
| yarn add @dvgis/dc-sdk | |||
| npm install @dvgis/dc-sdk | |||
| ``` | |||
| ```js | |||
| @@ -128,7 +130,7 @@ module.exports = { | |||
| ```js | |||
| global.DC = DC | |||
| DC.use(DcCore) | |||
| DC.use(DcCore) // node | |||
| DC.ready(() => { | |||
| let viewer = new DC.Viewer(divId) // divId is the Id attribute value of a div node. If it is not passed in, the 3D scene cannot be initialized | |||
| }) | |||
| @@ -136,15 +138,15 @@ DC.ready(() => { | |||
| ## Documentation | |||
| [DC Api](https://resource.dvgis.cn/dc-api) | |||
| [DC Sdk Api](https://resource.dvgis.cn/dc-api) | |||
| [Cesium Api](https://cesium.com/docs/cesiumjs-ref-doc/) | |||
| ## Demo | |||
| |  |  |  |  | | |||
| |  |  |  |  | | |||
| | :-----------------------------------------------------------: | :-----------------------------------------------------------: | :------------------------------------------------------------------: | :--------------------------------------------------------------: | | |||
| |  |  |  |  | | |||
| |  |  |  |  | | |||
| |  |  |  |  | | |||
| [More>>](http://dc.dvgis.cn/#/examples) | |||
| @@ -11,7 +11,9 @@ | |||
| > DC-SDK 是基于 Cesium 进行二次开发的2、3D一体 WebGis 应用框架,该框架优化了 Cesium 的使用方式和增添了一些额外功能,旨在为开发者快速构建 WebGis 应用。 | |||
| > [主页](http://dc.dvgis.cn) | |||
| ##主页 | |||
| > http://dc.dvgis.cn | |||
| ```warning | |||
| Tips:本框架是 JS+GIS 的框架包。开发者需要有一定的前端技术和 GIS 相关技术 | |||
| @@ -33,8 +35,8 @@ Tips:本框架是 JS+GIS 的框架包。开发者需要有一定的前端技 | |||
| `NPM / YARN` | |||
| ```shell | |||
| yarn add @dvgis/dc-sdk | |||
| npm install @dvgis/dc-sdk | |||
| yarn add @dvgis/dc-sdk | |||
| npm install @dvgis/dc-sdk | |||
| ``` | |||
| ```js | |||
| @@ -128,7 +130,7 @@ module.exports = { | |||
| ```js | |||
| global.DC = DC | |||
| DC.use(DcCore) | |||
| DC.use(DcCore) // Node 方式 | |||
| DC.ready(() => { | |||
| let viewer = new DC.Viewer(divId) // divId 为一个div节点的Id属性值,如果不传入,会无法初始化3D场景 | |||
| }) | |||
| @@ -136,15 +138,15 @@ DC.ready(() => { | |||
| ## 文档 | |||
| [DC Api](https://resource.dvgis.cn/dc-api) | |||
| [DC Sdk Api](https://resource.dvgis.cn/dc-api) | |||
| [Cesium Api](https://cesium.com/docs/cesiumjs-ref-doc/) | |||
| ## 示例 | |||
| |  |  |  |  | | |||
| |  |  |  |  | | |||
| | :-----------------------------------------------------------: | :-----------------------------------------------------------: | :------------------------------------------------------------------: | :--------------------------------------------------------------: | | |||
| |  |  |  |  | | |||
| |  |  |  |  | | |||
| |  |  |  |  | | |||
| [更多>>](http://dc.dvgis.cn/#/examples) | |||
| @@ -1,6 +1,6 @@ | |||
| { | |||
| "name": "@dvgis/dc-sdk", | |||
| "version": "1.14.0", | |||
| "version": "1.14.1", | |||
| "description": " The SDK is a secondary development based on the open source project Cesium, which optimizes some operations of Cesium and enables developers to quickly develop 3D applications through the framework.", | |||
| "main": "index.js", | |||
| "repository": "https://github.com/dvgis/dc-sdk.git", | |||
| @@ -0,0 +1,52 @@ | |||
| /** | |||
| * @Author: Caven | |||
| * @Date: 2020-01-19 13:38:48 | |||
| */ | |||
| import State from '../state/State' | |||
| import Layer from './Layer' | |||
| const { Cesium } = DC.Namespace | |||
| class CzmlLayer extends Layer { | |||
| constructor(id, url = '', options = {}) { | |||
| super(id) | |||
| this._delegate = Cesium.CzmlDataSource.load(url, options) | |||
| this.type = Layer.getLayerType('czml') | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set show(show) { | |||
| this._show = show | |||
| this._delegate && | |||
| this._delegate.then(dataSource => { | |||
| dataSource.show = this._show | |||
| }) | |||
| } | |||
| get show() { | |||
| return this._show | |||
| } | |||
| /** | |||
| * | |||
| * @param method | |||
| * @param context | |||
| * @returns {CzmlLayer} | |||
| */ | |||
| eachOverlay(method, context) { | |||
| if (this._delegate) { | |||
| this._delegate.then(dataSource => { | |||
| let entities = dataSource.entities.values | |||
| entities.forEach(item => { | |||
| method.call(context, item) | |||
| }) | |||
| }) | |||
| return this | |||
| } | |||
| } | |||
| } | |||
| Layer.registerType('czml') | |||
| export default CzmlLayer | |||
| @@ -0,0 +1,49 @@ | |||
| /** | |||
| * @Author: Caven | |||
| * @Date: 2020-01-19 11:03:17 | |||
| */ | |||
| import State from '../state/State' | |||
| import Layer from './Layer' | |||
| const { Cesium } = DC.Namespace | |||
| class KmlLayer extends Layer { | |||
| constructor(id, url, options = {}) { | |||
| if (!url) { | |||
| throw new Error('KmlLayer: the url is empty') | |||
| } | |||
| super(id) | |||
| this._delegate = Cesium.KmlDataSource.load(url, options) | |||
| this.type = Layer.getLayerType('kml') | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set show(show) { | |||
| this._show = show | |||
| this._delegate && | |||
| this._delegate.then(dataSource => { | |||
| dataSource.show = this._show | |||
| }) | |||
| } | |||
| get show() { | |||
| return this._show | |||
| } | |||
| eachOverlay(method, context) { | |||
| if (this._delegate) { | |||
| this._delegate.then(dataSource => { | |||
| let entities = dataSource.entities.values | |||
| entities.forEach(item => { | |||
| method.call(context, item) | |||
| }) | |||
| }) | |||
| return this | |||
| } | |||
| } | |||
| } | |||
| Layer.registerType('kml') | |||
| export default KmlLayer | |||