CesiumMap 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>无锡市汛期水文监测系统 - 2025乙巳蛇年</title>
  7. <!-- Cesium核心依赖 -->
  8. <link href="https://cesium.com/downloads/cesiumjs/releases/1.107/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
  9. <script src="https://cesium.com/downloads/cesiumjs/releases/1.107/Build/Cesium/Cesium.js"></script>
  10. <style>
  11. #cesium-container {
  12. width: 100%;
  13. height: 100vh;
  14. position: relative;
  15. }
  16. .water-level-panel {
  17. position: absolute;
  18. bottom: 20px;
  19. right: 20px;
  20. background: rgba(12, 45, 70, 0.85);
  21. padding: 15px;
  22. border-radius: 8px;
  23. color: white;
  24. font-family: "Microsoft YaHei", sans-serif;
  25. z-index: 100;
  26. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  27. }
  28. .lunar-date {
  29. position: absolute;
  30. top: 20px;
  31. left: 20px;
  32. background: rgba(70, 130, 180, 0.8);
  33. padding: 10px 15px;
  34. border-radius: 6px;
  35. color: white;
  36. font-size: 1.1em;
  37. z-index: 100;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div id="map-container" class="map-container"></div>
  43. <script>
  44. import { ref, onMounted, onUnmounted } from 'vue'
  45. import AMapLoader from '@amap/amap-jsapi-loader'
  46. import Header from './header.vue'
  47. import Gradientoverlay from './gradient-overlay.vue'
  48. import Leftmoudle from './leftmodul.vue'
  49. import Rightmoudle from './rightmodul.vue'
  50. import Middlemoudle from './middlemodul.vue'
  51. // 地图实例
  52. const map = ref(null)
  53. // 地图配置
  54. const mapConfig = {
  55. viewMode: '3D',
  56. zoom: 13,
  57. center: [120.21937542, 31.568152],
  58. pitch: 45,
  59. features: ['bg', 'road', 'building'],
  60. buildingAnimation: true,
  61. showLabel: false
  62. }
  63. // 初始化地图
  64. const initMap = async () => {
  65. try {
  66. window._AMapSecurityConfig = {
  67. securityJsCode: 'b87476c68ed625e2d337f160d0ba6122'
  68. }
  69. const AMap = await AMapLoader.load({
  70. key: '694aba7c51008bf8c08afc94aa566fc1',
  71. version: '2.0',
  72. plugins: ['AMap.Scale', 'AMap.ToolBar']
  73. })
  74. map.value = new AMap.Map('map-container', {
  75. ...mapConfig,
  76. layers: [
  77. new AMap.TileLayer.Satellite(),
  78. new AMap.TileLayer.RoadNet()
  79. ]
  80. })
  81. // 添加控件
  82. map.value.addControl(new AMap.Scale())
  83. map.value.addControl(new AMap.ToolBar())
  84. } catch (error) {
  85. console.error('地图初始化失败:', error)
  86. alert('高德地图加载失败,请检查控制台错误')
  87. }
  88. }
  89. // 生命周期
  90. onMounted(() => initMap())
  91. onUnmounted(() => map.value?.destroy())
  92. </script>
  93. </body>
  94. </html>