0.7.2 • Published 2 years ago

keep-globe v0.7.2

Weekly downloads
207
License
-
Repository
-
Last release
2 years ago

keep-globe

基于cesium 三维vue组件封装

安装

npm install keep-globe --save
npm install echarts @turf/turf cesium --save
npm install leaflet --save

配置

因为模型文件较大,未打包到代码 如需使用漫游功能需要进行如下配置

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,需单独安装

import Cesium from 'cesium';
import keepGlobe from 'keep-globe';
import 'keep-globe/dist/keep-globe.css';
Vue.use(keepGlobe);

示例

<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>

附Cesium 引入方法

1.npm 引入 (有资源文件以及三方worker )

安装

npm install cesium --save

配置

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('')
    })
    ]
  }
}

引入

import * as Cesium from 'cesium'

2.CDN 引入

<!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>
0.7.2

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.9

3 years ago

0.5.8

3 years ago

0.5.7

3 years ago

0.5.6

3 years ago

0.5.5

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago