卫星扫描

雷达扫描、卫星扫描、圆形/扇形/锥形扫描与矩阵控制。下面是该示例的核心 script 片段,供参考学习;完整可运行代码请进入在线 Demo 或查看仓库源码。

在线运行 Demo 全部示例 查看完整源码

示例代码

import * as Cesium from 'cesium'
import { initCesium } from '@/utils/cesiumPluginsExtends/index'

export default {
  mounted () {
    this.initMap()
  },
  methods: {
    initMap () {
      const { viewer, passEffect, graphics } = new initCesium(
        {
          cesiumGlobal: Cesium,
          containerId: 'cesiumContainer',
          viewerConfig: {
            infoBox: false,
            shouldAnimate: true,
          },
          extraConfig: {},
          MapImageryList: []
        })

      this.c_viewer = viewer;
      this.passEffect = passEffect;
      this.graphics = graphics;
      this.createRadarScan();
      this.graphics.flyTo({
        position: {
          x: -2346830.2203772613,
          y: 4466707.7134610135,
          z: 4113849.456869386
        },
        orientation: {
          heading: Cesium.Math.toRadians(299.9133567470365),
          pitch: Cesium.Math.toRadians(-43.32853926465136),
          roll: Cesium.Math.toRadians(0.12183910428719429)
        },
      })
      this.getClickPosition()
    },
    // 左键点击获取相机位置
    getClickPosition () {
      var $this = this;
      this.passEffect.bindHandelEvent({
        leftClick: function click (event, _handlers) {
          const pos = $this.passEffect.getCameraPosition();
          console.log(pos);
        }
      })
    },
    createRadarScan () {
      this.graphics.createPointsGraphics({
        positions: [Cesium.Cartesian3.fromDegrees(116.39, 39.9, 40000.0)],
        billboard: {
          b_img: 'static/data/images/file/satellite.svg',
          b_width: 50,
          b_height: 40,
          b_scale: 1,
          b_pixelOffset: new Cesium.Cartesian2(20, -10)
        }
      })
      this.passEffect.satelliteScan({
        position: [116.39, 39.9],
        length: 40000.0,
        color: Cesium.Color.LIGHTGREEN,
        repeat: 40,
        thickness: 0.1
      })
    }
  },
  beforeUnmount () {
    this.c_viewer = null;
    this.passEffect = null;
  }
}

相关 API

安装:npm install cesium_dev_kit cesium