index.vue 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div id="cesiumContainer"></div>
  3. </template>
  4. <script setup lang="ts">
  5. import { onMounted } from "vue";
  6. import { Viewer, Rectangle, Ion, createWorldTerrainAsync } from "cesium";
  7. import CesiumNavigation from "cesium-navigation-es6";
  8. onMounted(async () => {
  9. Ion.defaultAccessToken =
  10. "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3MTNiMzk1My0zZmRlLTRmYjQtYTBlZC0wMTdhYjAzMTFiMTAiLCJpZCI6MTQ3NjQsInNjb3BlcyI6WyJhc2wiLCJhc3IiLCJhc3ciLCJnYyJdLCJpYXQiOjE1NjYzMDc3NjZ9.ddc1YqTozjcAmoYQBE2Na5gr8RClBNKeB8QfkAwyPqk";
  11. window.Viewer = new Viewer("cesiumContainer", {
  12. animation: true, // * 左下角圆盘 速度控制器
  13. shouldAnimate: true, // * 当动画控件出现,用来控制是否通过旋转控件,旋转场景
  14. baseLayerPicker: false, // * 右上角图层选择器
  15. fullscreenButton: false, // * 右下角全屏按钮
  16. vrButton: false, // * 右下角vr按钮
  17. homeButton: false, // * 右上角地图恢复到初始页面按钮
  18. selectionIndicator: false, // * 点击后地图上显示的选择控件
  19. infoBox: false, // * 右上角鼠标点击后信息展示框
  20. sceneModePicker: false, // * 右上角2D和3D之间的切换
  21. timeline: true, // * 页面下方的时间条
  22. navigationHelpButton: false, // * 右上角帮助按钮
  23. navigationInstructionsInitiallyVisible: false, // * 是否展开帮助
  24. scene3DOnly: true, // * 如果设置为true,则所有几何图形以3D模式绘制以节约GPU资源
  25. useDefaultRenderLoop: true, // * 控制渲染循环
  26. showRenderLoopErrors: false, // * HTML面板中显示错误信息
  27. useBrowserRecommendedResolution: true, // * 如果为true,则以浏览器建议的分辨率渲染并忽略window.devicePixelRatio
  28. automaticallyTrackDataSourceClocks: true, // * 自动追踪最近添加的数据源的时钟设置
  29. orderIndependentTranslucency: true, // * 如果为true并且配置支持它,则使用顺序无关的半透明性
  30. shadows: false, // * 阴影效果
  31. projectionPicker: false, // * 透视投影和正投影之间切换
  32. requestRenderMode: true, // * 在指定情况下进行渲染,提高性能
  33. terrainProvider: await createWorldTerrainAsync(),
  34. });
  35. window.Viewer._cesiumWidget._creditContainer.style.display = "none"; // * 隐藏版权信息
  36. window.Viewer.scene.globe.depthTestAgainstTerrain = true; // * 开启深度测试
  37. interface CesiumNavigationOptions {
  38. defaultResetView: Rectangle; // * 用于在使用重置导航重置地图视图时设置默认视图控制。接受的值是Cesium.Cartographic 和 Cesium.Rectangle.
  39. enableCompass: boolean; // * 用于启用或禁用罗盘。true是启用罗盘,false是禁用罗盘。默认值为true。如果将选项设置为false,则罗盘将不会添加到地图中。
  40. enableZoomControls: boolean; // * 用于启用或禁用缩放控件。true是启用,false是禁用。默认值为true。如果将选项设置为false,则缩放控件将不会添加到地图中。
  41. enableDistanceLegend: boolean; // * 用于启用或禁用比例尺。true是启用,false是禁用。默认值为true。如果将选项设置为false,比例尺将不会添加到地图中。
  42. enableCompassOuterRing: boolean; // * 用于启用或禁用指南针外环。true是启用,false是禁用。默认值为true。如果将选项设置为false,则该环将可见但无效。
  43. }
  44. var options: CesiumNavigationOptions = {
  45. defaultResetView: Rectangle.fromDegrees(80, 22, 130, 50),
  46. enableCompass: true,
  47. enableZoomControls: false,
  48. enableDistanceLegend: false,
  49. enableCompassOuterRing: true,
  50. };
  51. new CesiumNavigation(window.Viewer, options);
  52. });
  53. </script>
  54. <style scoped>
  55. #cesiumContainer {
  56. width: 100%;
  57. height: 100%;
  58. }
  59. </style>