UVA.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>三维-轨迹回放</title>
  7. <link rel="stylesheet" href="../../dist/index.css" />
  8. <script src="../../dist/index.js"></script>
  9. <link href="../../cesium/Source/Widgets/widgets.css" rel="stylesheet">
  10. <script src="../../cesium/Build/Cesium/Cesium.js"></script>
  11. </head>
  12. <body style="margin: 0; padding: 0;">
  13. <div id="map" style="height: 100vh; width: 100vw;"></div>
  14. <div class="input-card">
  15. <div class="input-item">
  16. <button id="doPlay">播放</button>
  17. <button id="pause">暂停</button>
  18. <button id="next">前进</button>
  19. <button id="prev">后退</button>
  20. <button id="show">显示</button>
  21. <button id="hide">隐藏</button>
  22. <button id="remove">删除</button>
  23. <button id="addPath">添加新路径</button>
  24. <p>
  25. <input id="range" type="range" min="0" max="1" style="width: 80%"
  26. step="0.001" value="0">
  27. </p>
  28. </div>
  29. </div>
  30. </body>
  31. <script>
  32. const viewer = new Cesium.Viewer("map", {
  33. // homeButton: false, // 是否显示首页按钮
  34. // geocoder: false, // 是否显示输入地名查找控件
  35. sceneModePicker: false, // 是否显示投影方式控件(包含二维及三维投影)
  36. // baseLayerPicker: false, // 是否显示帮助控件
  37. creditDisplay: false,
  38. // timeline: true,
  39. // infoBox: false, // 是否显示点击要素之后显示的信息
  40. selectionIndicator: false,
  41. imageryProvider: false,
  42. fullscreenButton: false
  43. })
  44. let pData = [
  45. [116.41136, 39.97569],
  46. [116.411794, 39.9068],
  47. [116.32969, 39.92940],
  48. [116.385438, 39.90610],
  49. ]
  50. let polyline = new CTMapOl.cesiumComponent.Polyline({
  51. path: pData,
  52. zoomto: true,
  53. strokeOpacity:0.8,
  54. });
  55. polyline.addTo({ viewer })
  56. var car = new CTMapOl.cesiumComponent.UVA(viewer, {
  57. btnBox: 150, // 左边按钮的盒子宽度
  58. bgColor: 'rgba(0,0,0,0.3)', // 控件的背景色
  59. width: 18, // 飞行器的宽度
  60. height: 27, // 飞行器的高度
  61. anchor: [9, 20], // 原点偏移
  62. path: pData, // 路径坐标;二维数组
  63. duration: 10000, // 播放时间
  64. onPlay: (info) => {
  65. let rangeV = document.getElementById('range')
  66. rangeV.value = info.progress
  67. }
  68. })
  69. car.addTo({ viewer });
  70. document.getElementById('doPlay').onclick = () => {
  71. car.play();
  72. }
  73. document.getElementById('pause').onclick = () => {
  74. car.pause();
  75. }
  76. document.getElementById('next').onclick = () => {
  77. car.fastFront();
  78. }
  79. document.getElementById('prev').onclick = () => {
  80. car.fastBack();
  81. }
  82. document.getElementById('hide').onclick = () => {
  83. car.hide();
  84. }
  85. document.getElementById('show').onclick = () => {
  86. car.show();
  87. }
  88. document.getElementById('remove').onclick = () => {
  89. car.remove();
  90. }
  91. document.getElementById('addPath').onclick = () => {
  92. let path = [
  93. [116.385438, 39.90610], // 上一个路径的终点
  94. [116.485438, 39.90610],
  95. ]
  96. let polyline = new CTMapOl.cesiumComponent.Polyline({
  97. path,
  98. strokeOpacity:0.8,
  99. strokeColor: 'red'
  100. })
  101. polyline.addTo({ viewer: map.Viewer })
  102. car.addPath({
  103. path: path.slice(1),
  104. distance: 0.02,
  105. duration: 1000, // 飞行时间
  106. })
  107. }
  108. document.getElementById('range').oninput = (e) => {
  109. car.moveTo(e.target.value)
  110. }
  111. </script>
  112. <style>
  113. /*地图*/
  114. .mapDIV {
  115. height: 100vh;
  116. width: 100vw;
  117. z-index: 1;
  118. }
  119. .add-switch {
  120. position: absolute;
  121. right: 30px;
  122. height: 68px;
  123. width: 30px;
  124. bottom: 112px;
  125. background: #FFFFFF 100%;
  126. color: #172537;
  127. border-radius: 4px;
  128. display: flex;
  129. flex-direction: column;
  130. align-items: center;
  131. z-index: 2;
  132. }
  133. .add-s-block {
  134. height: 20px;
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. width: 100%;
  139. line-height: 20px;
  140. font-size: 12px;
  141. margin-bottom: 2px;
  142. color: #172537;
  143. }
  144. .add-zoom {
  145. width: 20px;
  146. height: 20px;
  147. background-image: url('../../dist/assets/image/ar/switch/add-zoom.svg');
  148. background-size: 100% 100%;
  149. cursor: pointer;
  150. }
  151. .sub-zoom {
  152. width: 20px;
  153. height: 20px;
  154. background-image: url('../../dist/assets/image/ar/switch/sub-zoom.svg');
  155. background-size: 100% 100%;
  156. cursor: pointer;
  157. }
  158. .add-zoom-out {
  159. width: 20px;
  160. height: 20px;
  161. background-image: url('../../dist/assets/image/ar/switch/add-zoom-out.svg');
  162. background-size: 100% 100%;
  163. }
  164. .sub-zoom-out {
  165. width: 20px;
  166. height: 20px;
  167. background-image: url('../../dist/assets/image/ar/switch/sub-zoom-out.svg');
  168. background-size: 100% 100%;
  169. }
  170. .add-s-block.btn-click {
  171. cursor: pointer;
  172. }
  173. .input-card {
  174. position: absolute;
  175. left: 15px;
  176. top: 15px;
  177. z-index: 999;
  178. }
  179. </style>
  180. </html>