# keep-globe

> 基于cesium 三维vue组件封装

Latest version **0.7.2** (published 2022-04-21) · 0 weekly downloads

## Install

```sh
npm install keep-globe
pnpm add keep-globe
yarn add keep-globe
bun add keep-globe
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; large bundle; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.2 |
| Published | 2022-04-21 |
| First published | 2020-10-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 16 |
| Unpacked size | 16.7 MB |
| Known vulnerabilities | 0 (+27 in 3 direct dependencies) |
| Install scripts | no |
| Maintainers | bfzhao, engineerhe |

## Links

- npm: https://www.npmjs.com/package/keep-globe
- npm.io page: https://npm.io/package/keep-globe

## Dependencies (16)

- [qs](https://npm.io/package/qs.md) ^6.9.6
- [vue](https://npm.io/package/vue.md) ^2.6.11
- [axios](https://npm.io/package/axios.md) ^0.19.2
- [cesium](https://npm.io/package/cesium.md) ^1.92.0
- [jquery](https://npm.io/package/jquery.md) ^3.5.1
- [core-js](https://npm.io/package/core-js.md) ^3.6.5
- [echarts](https://npm.io/package/echarts.md) ^4.8.0
- [leaflet](https://npm.io/package/leaflet.md) ^1.7.1
- [@turf/turf](https://npm.io/package/@turf/turf.md) ^5.1.6
- [element-ui](https://npm.io/package/element-ui.md) ^2.13.2
- [file-saver](https://npm.io/package/file-saver.md) ^2.0.2
- [vue-router](https://npm.io/package/vue-router.md) ^3.3.4
- [net-analysis](https://npm.io/package/net-analysis.md) ^0.5.0
- [vue-codemirror](https://npm.io/package/vue-codemirror.md) ^4.0.6
- [@sakitam-gis/kriging](https://npm.io/package/@sakitam-gis/kriging.md) ^0.1.0
- [@open-wc/webpack-import-meta-loader](https://npm.io/package/@open-wc/webpack-import-meta-loader.md) ^0.4.7

## Recent versions

- 0.7.2 (latest) — 2022-04-21
- 0.7.1 — 2022-04-21
- 0.7.0 — 2021-12-20
- 0.6.0 — 2021-11-12
- 0.5.9 — 2021-09-17
- 0.5.8 — 2021-09-07
- 0.5.7 — 2021-09-07
- 0.5.6 — 2021-08-11
- 0.5.5 — 2021-08-05
- 0.5.4 — 2021-07-28
- 0.5.3 — 2021-07-22
- 0.5.2 — 2021-06-16
- 0.5.1 — 2021-06-04
- 0.5.0 — 2021-05-25
- 0.1.12 — 2021-01-26
- … 21 more at https://npm.io/package/keep-globe/versions

## README

# keep-globe
基于cesium 三维vue组件封装

# 安装 
```shell
npm install keep-globe --save
npm install echarts @turf/turf cesium --save
npm install leaflet --save
```

# 配置
因为模型文件较大，未打包到代码 如需使用漫游功能需要进行如下配置
```javascript
const CopyWebpackPlugin = require('copy-webpack-plugin')
const path = require("path");

module.exports = {
  productionSourceMap: false,
  configureWebpack: config => {
    // 拷贝模型文件到项目目录
    config.plugins.push(new CopyWebpackPlugin([{ from: path.join('./node_modules/keep-globe/dist', 'models'), to: 'models' }]))
  }
};
```

# 使用
组件库中不包括Cesium，需单独安装
``` javascript
import Cesium from 'cesium';
import keepGlobe from 'keep-globe';
import 'keep-globe/dist/keep-globe.css';
Vue.use(keepGlobe);
```

# 示例

```html
<template>
  <div style="width: 100%; height: 600px;">
    <gui-globe ref="globe"></gui-globe>
    <div>
      <button @click="flyTo">飞行至</button>
      <button @click="setView">设置视角</button>
    </div>
  </div>
</template>
<script>
export default {
  mounted () {
    const options = {
      viewer: {
        basemap: { type: 'TDTIMAGE' },
        initView: {
          destination: [114.312079, 30.358405, 50000],
          orientation: {
            heading: 0,
            pitch: -60,
            roll: 0.0
          }
        }
      },
      controls: {
        mapMeasure: {
          show: true
        },
        dimensionSwitch: {
          show: true
        }
      }
    }
    this.$refs.globe.init(options)
  },
  methods: {
    flyTo(){
      const options = {
        destination: [113.312079, 30.358405, 50000],
        orientation: {
          heading: 0,
          pitch: -90,
          roll: 0.0
        }
      }
      this.$refs.globe.cameraFlyTo(options)
    },
    setView(){
      const options = {
        destination: [113.312079, 33.358405, 1000000],
        orientation: {
          heading: 0,
          pitch: -45,
          roll: 0.0
        }
      }
      this.$refs.globe.setCameraView(options)
    }
  }
}
</script>

```
<br/>

# 附Cesium 引入方法
## 1.npm 引入 （有资源文件以及三方worker ）
### 安装
```shell
npm install cesium --save
```
### 配置 
```javascript
const CopyWebpackPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')
module.exports = {
  configureWebpack: {
    plugins: [
      new CopyWebpackPlugin(
      [
        { from: 'node_modules/cesium/Build/Cesium/Workers', to: 'Workers' },
        { from: 'node_modules/cesium/Build/Cesium/ThirdParty', to: 'ThirdParty' },
        { from: 'node_modules/cesium/Build/Cesium/Assets', to: 'Assets' },
        { from: 'node_modules/cesium/Build/Cesium/Widgets', to: 'Widgets' }
      ]
    )
    new webpack.DefinePlugin({
      CESIUM_BASE_URL: JSON.stringify('')
    })
    ]
  }
}


```
### 引入
```shell
import * as Cesium from 'cesium'
```

## 2.CDN 引入
```html
<!DOCTYPE html>

<head>
  ...
  <link rel="stylesheet" type="text/css" href="https://unpkg.com/cesium@1.73.0/Build/Cesium/Widgets/widgets.css">
  ...
</head>

<body>
  ...
  <script src="https://unpkg.com/cesium@1.73.0/Build/Cesium/Cesium.js"></script>
  ...
</body>

</html>
```

---
_Source: https://npm.io/package/keep-globe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
