arcgis地图

百度、腾讯、天地图、ArcGIS、聚合、3D 柱与卷帘对比。下面是该示例的核心 script 片段,供参考学习;完整可运行代码请进入在线 Demo 或查看仓库源码。

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

示例代码

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

export default {
  data () {
    return {
      activeId: 'light'
    }
  },
  mounted () {
    this.initMap()
  },
  methods: {
    async initMap () {
      const {
        viewer,
        control,
      } = new initCesium(
        {
          cesiumGlobal: Cesium,
          containerId: 'cesiumContainer',
          viewerConfig: {
            infoBox: false,
            shouldAnimate: true,
          },
          extraConfig: {},
          MapImageryList: []
        })
      this.c_viewer = viewer;

      this.control = control;

      const esriLayer = await Cesium.ArcGisMapServerImageryProvider.fromUrl(
        'https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer');
      let layer = this.c_viewer.imageryLayers.addImageryProvider(esriLayer);
      layer.name = '电子'; layer.id = 'layer1'; layer.show = true;

      const esriLayer2 = await Cesium.ArcGisMapServerImageryProvider.fromUrl(
        'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer');
      let layer2 = this.c_viewer.imageryLayers.addImageryProvider(esriLayer2);
      layer2.name = '影像'; layer2.id = 'layer2'; layer2.show = false;


      const esriLayer3 = await Cesium.ArcGisMapServerImageryProvider.fromUrl(
        'https://services.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer');
      let layer3 = this.c_viewer.imageryLayers.addImageryProvider(esriLayer3);
      layer3.name = '地形'; layer3.id = 'layer3'; layer3.show = false;

      const esriLayer4 = await Cesium.ArcGisMapServerImageryProvider.fromUrl(
        'https://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer');
      let layer4 = this.c_viewer.imageryLayers.addImageryProvider(esriLayer4);
      layer4.name = '地形2'; layer4.id = 'layer4'; layer4.show = false;

      this.control.showLayerSwitchPanel([layer, layer2, layer3, layer4], { elementId: 'cust-gui-box' })
      this.flyto();
    },
    flyto () {
      this.control.flyTo({
        position: { x: -1337132.0092982147, y: 5330611.474631115, z: 3228680.029449292 },
        orientation: {
          heading: Cesium.Math.toRadians(1.0114629015290062),
          pitch: Cesium.Math.toRadians(-43.53661660731824),
          roll: Cesium.Math.toRadians(0.20324596311071617)
        }
      })
    },
  },
  beforeUnmount () {
    this.c_viewer = null;
    this.control = null;
  }
}

相关 API

安装:npm install cesium_dev_kit cesium