f65_roamLine_plane.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <!-- 2017-12-7 14:56:03 | 修改 木遥(微信: http://marsgis.cn/weixin.html ) -->
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  7. <meta name="apple-touch-fullscreen" content="yes" />
  8. <meta name="apple-mobile-web-app-capable" content="yes" />
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  10. <meta name="format-detection" content="telephone=no" />
  11. <meta name="x5-fullscreen" content="true" />
  12. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
  13. <!-- 标题及搜索关键字 -->
  14. <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
  15. <meta
  16. name="description"
  17. content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
  18. />
  19. <link rel="shortcut icon" type="image/x-icon" href="" />
  20. <title>飞行路线 </title>
  21. <script
  22. type="text/javascript"
  23. src="../lib/include-lib.js"
  24. libpath="../lib/"
  25. include="jquery,font-awesome,bootstrap,bootstrap-checkbox,bootstrap-slider,layer,haoutil,turf,mars3d"
  26. ></script>
  27. <link href="../lib/jquery/select/jqSelect.css" rel="stylesheet" />
  28. <script src="../lib/jquery/select/jqSelect.js"></script>
  29. <link href="css/style.css" rel="stylesheet" />
  30. <style>
  31. .mp_table {
  32. width: 100%;
  33. border: #cde1de 1px solid;
  34. font-size: 12px;
  35. border-collapse: collapse;
  36. border-spacing: 0;
  37. }
  38. .mp_table tr td {
  39. padding: 5px 5px;
  40. text-align: left;
  41. border: #cde1de 1px solid;
  42. }
  43. .mp_table tr td:first-child {
  44. border-left: none;
  45. }
  46. .nametd {
  47. width: 40%;
  48. }
  49. .mp_input {
  50. height: 28px;
  51. line-height: 22px;
  52. padding: 3px 5px;
  53. box-sizing: border-box;
  54. font-size: 12px;
  55. border: 1px solid #e6e6e6;
  56. background-color: #fff;
  57. border-radius: 3px;
  58. display: block;
  59. width: 100%;
  60. outline: 0;
  61. box-sizing: border-box;
  62. }
  63. .mp_input:hover {
  64. border-color: #c9c9c9 !important;
  65. }
  66. .mp_input:focus {
  67. border-color: #3374e0 !important;
  68. }
  69. .mp_head2 {
  70. width: 100%;
  71. height: 45px;
  72. line-height: 45px;
  73. text-align: center;
  74. }
  75. .dark .progress {
  76. margin: 0;
  77. background-color: #0b2931;
  78. }
  79. .slider.slider-horizontal {
  80. width: 144px;
  81. height: 20px;
  82. margin-left: 10px;
  83. }
  84. </style>
  85. </head>
  86. <body class="dark">
  87. <!--加载前进行操作提示,优化用户体验-->
  88. <div id="mask" class="signmask" onclick="removeMask()"></div>
  89. <div id="mars3dContainer" class="mars3d-container"></div>
  90. <!-- 控制 面板 -->
  91. <div class="infoview">
  92. <input id="btnStart" type="button" class="btn btn-primary" value="开始" />
  93. <input id="btnPause" type="button" class="btn btn-primary" value="暂停" />
  94. <input id="btnStop" type="button" class="btn btn-primary" value="停止" />
  95. <table class="mp_table">
  96. <tr>
  97. <td class="nametd">漫游视角</td>
  98. <td>
  99. <select id="cameraType" class="mp_select" data-value="2">
  100. <option value="">自由视角</option>
  101. <option value="gs">跟随视角</option>
  102. <option value="dy">锁定第一视角</option>
  103. <option value="sd">锁定上帝视角</option>
  104. </select>
  105. </td>
  106. </tr>
  107. <tr id="tr_followedX" title="距离漫游对象的水平距离,单位:米">
  108. <td class="nametd">视角距离</td>
  109. <td>
  110. <input id="followedX" type="number" min="0" max="99999" value="1" class="mp_input" />
  111. </td>
  112. </tr>
  113. <tr id="tr_followedZ" title="距离漫游对象的高度,单位:米">
  114. <td class="nametd">视角高度</td>
  115. <td>
  116. <input id="followedZ" type="number" min="0" max="99999" value="0" class="mp_input" />
  117. </td>
  118. </tr>
  119. <tr id="tr_offsetZ" title="偏离漫游对象的高度,单位:米">
  120. <td class="nametd">高度偏移值</td>
  121. <td>
  122. <input id="offsetZ" type="number" min="-9999" max="9999" value="0" step="0.1" class="mp_input" />
  123. </td>
  124. </tr>
  125. <tr id="tr_offsetY" title="偏离漫游对象的横向值,单位:米">
  126. <td class="nametd">横向偏移值</td>
  127. <td>
  128. <input id="offsetY" type="number" min="-9999" max="9999" value="0" step="0.1" class="mp_input" />
  129. </td>
  130. </tr>
  131. <tr id="tr_offsetX" title="偏离漫游对象的前后值,单位:米">
  132. <td class="nametd">前后偏移值</td>
  133. <td>
  134. <input id="offsetX" type="number" min="-9999" max="9999" value="0" step="0.1" class="mp_input" />
  135. </td>
  136. </tr>
  137. <tr>
  138. <td class="nametd">模型角度</td>
  139. <td style="min-width: 130px">
  140. <div class="radio radio-info radio-inline">
  141. <input type="radio" id="jiaodu_1" value="1" name="jiaodu" checked />
  142. <label for="jiaodu_1">自动</label>
  143. </div>
  144. <div class="radio radio-info radio-inline">
  145. <input type="radio" id="jiaodu_2" value="2" name="jiaodu" />
  146. <label for="jiaodu_2">手动</label>
  147. </div>
  148. </td>
  149. </tr>
  150. <tr class="jiaodu_2_angele">
  151. <td class="nametd">heading值</td>
  152. <td>
  153. 根据路线自动计算
  154. <!--<input id="model_heading" type="range" min="0" max="360" step="0.01" value="10" title="方向">-->
  155. </td>
  156. </tr>
  157. <tr class="jiaodu_2_angele">
  158. <td class="nametd">pitch值</td>
  159. <td>
  160. <input id="model_pitch"title="倾角pitch" />
  161. </td>
  162. </tr>
  163. <tr class="jiaodu_2_angele">
  164. <td class="nametd">roll值</td>
  165. <td>
  166. <input id="model_roll" title="滚动角roll" />
  167. </td>
  168. </tr>
  169. </table>
  170. </div>
  171. <!-- 信息 面板 -->
  172. <div class="infoview rightbottom" style="min-width: 200px">
  173. <table class="mp_table">
  174. <tr>
  175. <td class="nametd">总长度</td>
  176. <td id="td_alllength"></td>
  177. </tr>
  178. <tr>
  179. <td class="nametd">已漫游长度</td>
  180. <td id="td_length"></td>
  181. </tr>
  182. <tr>
  183. <td class="nametd">总时长</td>
  184. <td id="td_alltimes"></td>
  185. </tr>
  186. <tr>
  187. <td class="nametd">已漫游时间</td>
  188. <td id="td_times"></td>
  189. </tr>
  190. <tr>
  191. <td class="nametd">经度</td>
  192. <td id="td_jd"></td>
  193. </tr>
  194. <tr>
  195. <td class="nametd">经度</td>
  196. <td id="td_wd"></td>
  197. </tr>
  198. <tr>
  199. <td class="nametd">漫游高程</td>
  200. <td id="td_gd"></td>
  201. </tr>
  202. <tr>
  203. <td class="nametd">地面高程</td>
  204. <td id="td_dmhb"></td>
  205. </tr>
  206. <tr id="tr_ldgd">
  207. <td class="nametd">离地距离</td>
  208. <td id="td_ldgd"></td>
  209. </tr>
  210. <tr>
  211. <td colspan="2" style="width: 100%; text-align: center">
  212. <div class="progress">
  213. <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
  214. </div>
  215. </td>
  216. </tr>
  217. </table>
  218. </div>
  219. <script src="./js/common.js"></script>
  220. <script type="text/javascript">
  221. "use script"; //开发环境建议开启严格模式
  222. var map;
  223. var roamLine;
  224. function initMap(options) {
  225. //合并属性参数,可覆盖config.json中的对应配置
  226. var mapOptions = mars3d.Util.merge(options, {
  227. scene: {
  228. center: { lat: 30.859616, lng: 116.296235, alt: 445, heading: 258, pitch: -29 },
  229. },
  230. control: {
  231. animation: true, //是否创建动画小器件,左下角仪表
  232. timeline: true, //是否显示时间线控件
  233. },
  234. });
  235. //创建三维地球场景
  236. map = new mars3d.Map("mars3dContainer", mapOptions);
  237. //创建矢量数据图层
  238. var graphicLayer = new mars3d.layer.GraphicLayer();
  239. map.addLayer(graphicLayer);
  240. //该数据可以从 基础项目 飞行漫游功能界面操作后保存JSON
  241. var flydata = {
  242. name: "飞机航线",
  243. speed: 100,
  244. showStop: true,
  245. positions: [
  246. [116.295754, 30.859525, 418.5],
  247. [116.295699, 30.859754, 419.1],
  248. [116.295759, 30.860242, 422.2],
  249. [116.296109, 30.861108, 425.6],
  250. [116.296669, 30.862062, 428.8],
  251. [116.297105, 30.862978, 431.7],
  252. [116.297429, 30.863782, 432.2],
  253. [116.297829, 30.864648, 432.6],
  254. [116.298229, 30.865548, 432.7],
  255. [116.298639, 30.86646, 433.2],
  256. [116.299029, 30.867376, 433.8],
  257. [116.299369, 30.868276, 434.9],
  258. [116.299615, 30.869388, 438.5],
  259. [116.300039, 30.870338, 442.5],
  260. [116.300469, 30.871318, 445.5],
  261. [116.300904, 30.872262, 449.4],
  262. [116.301324, 30.873121, 454.2],
  263. [116.301599, 30.873975, 458.7],
  264. [116.301689, 30.875131, 463.9],
  265. [116.301579, 30.876368, 468.8],
  266. [116.301229, 30.877428, 473.7],
  267. [116.300774, 30.878442, 479.1],
  268. [116.300239, 30.879461, 486.1],
  269. [116.299729, 30.880532, 493.5],
  270. [116.299264, 30.881518, 500.9],
  271. [116.298709, 30.882543, 510],
  272. [116.284909, 30.885183, 1133.1],
  273. [116.283389, 30.884496, 1137.1],
  274. [116.282189, 30.883573, 1144.7],
  275. [116.281149, 30.882568, 1156.7],
  276. [116.280359, 30.881538, 1169.8],
  277. [116.279799, 30.880498, 1181.2],
  278. [116.279349, 30.879354, 1193.9],
  279. [116.279239, 30.878175, 1204.7],
  280. [116.279199, 30.877008, 1217.5],
  281. [116.278985, 30.875825, 1219.3],
  282. [116.278719, 30.874704, 1229.2],
  283. [116.278504, 30.873662, 1244],
  284. [116.278319, 30.872651, 1259.5],
  285. [116.278159, 30.871621, 1276.4],
  286. [116.278009, 30.870608, 1288.9],
  287. [116.277859, 30.869592, 1299.4],
  288. [116.277719, 30.868562, 1307.6],
  289. [116.277579, 30.867551, 1318.2],
  290. [116.277479, 30.866533, 1324.5],
  291. [116.277375, 30.865503, 1333.4],
  292. [116.277249, 30.864495, 1342.3],
  293. [116.277109, 30.863481, 1348.5],
  294. [116.276925, 30.862451, 1355.5],
  295. [116.276689, 30.861432, 1362.3],
  296. [116.276329, 30.860395, 1369.9],
  297. [116.275779, 30.859358, 1377.1],
  298. [116.274999, 30.858373, 1386.1],
  299. [116.274169, 30.857366, 1395.2],
  300. [116.273239, 30.856492, 1402.7],
  301. [116.272034, 30.855893, 1407.4],
  302. [116.270639, 30.855432, 1415.9],
  303. [116.269143, 30.855142, 1422.6],
  304. [116.267639, 30.85497, 1429.6],
  305. [116.266053, 30.855134, 1434.4],
  306. [116.264344, 30.855382, 1437.1],
  307. [116.262739, 30.855813, 1434.6],
  308. [116.261124, 30.856393, 1432.8],
  309. [116.259589, 30.856968, 1434.4],
  310. [116.258065, 30.857548, 1436.9],
  311. [116.258949, 30.864934, 1272.7],
  312. [116.259889, 30.865938, 1266.5],
  313. [116.260995, 30.866778, 1262],
  314. [116.262219, 30.867478, 1257.4],
  315. [116.263369, 30.868178, 1259.1],
  316. [116.264535, 30.868852, 1259.3],
  317. [116.265729, 30.86955, 1257.7],
  318. [116.266959, 30.870248, 1253.8],
  319. [116.268204, 30.870984, 1248.4],
  320. [116.269429, 30.871701, 1242.8],
  321. [116.270623, 30.872398, 1241.4],
  322. [116.271799, 30.873088, 1241.6],
  323. [116.272973, 30.873792, 1240.8],
  324. [116.274099, 30.874505, 1240.5],
  325. [116.275159, 30.875291, 1238.8],
  326. [116.276079, 30.876208, 1236.6],
  327. [116.276833, 30.877313, 1232.6],
  328. [116.277469, 30.878473, 1230.4],
  329. [116.278023, 30.879636, 1227.8],
  330. [116.278519, 30.880798, 1225.7],
  331. [116.279009, 30.881963, 1223.5],
  332. [116.279519, 30.883118, 1223.2],
  333. [116.280029, 30.884288, 1223.1],
  334. [116.280589, 30.885453, 1222.1],
  335. [116.281199, 30.886541, 1222.2],
  336. [116.281959, 30.887563, 1221.3],
  337. [116.282883, 30.88852, 1221.2],
  338. [116.283883, 30.889444, 1221.5],
  339. [116.284949, 30.89026, 1221.2],
  340. ],
  341. model: {
  342. show: true,
  343. url: "//data.mars3d.cn/gltf/mars/MQ-9-Predator.glb",
  344. scale: 1,
  345. minimumPixelSize: 100,
  346. },
  347. path: {
  348. show: true,
  349. color: "#ffff00",
  350. opacity: 0.5,
  351. width: 1,
  352. isAll: false,
  353. },
  354. shadow: [
  355. {
  356. show: true,
  357. type: "wall",
  358. surface: true,
  359. },
  360. ],
  361. camera: {
  362. type: "gs",
  363. heading: 30,
  364. radius: 500,
  365. },
  366. // "clockLoop": true, //是否循环播放,与 clockRange: Cesium.ClockRange.LOOP_STOP 效果类似,但不改变全局时钟时间。
  367. clockRange: Cesium.ClockRange.CLAMPED, //CLAMPED 到达终止时间后停止
  368. };
  369. roamLine = new mars3d.graphic.RoamLine(flydata);
  370. graphicLayer.addGraphic(roamLine);
  371. $("#btnStart").click(function () {
  372. //启动漫游
  373. roamLine.start();
  374. $("#btnPause").show().val("暂停");
  375. });
  376. $("#btnPause").hide();
  377. $("#btnPause").click(function () {
  378. if (roamLine.isPause) {
  379. roamLine.proceed(); //继续
  380. $(this).val("暂停");
  381. } else {
  382. roamLine.pause(); //暂停
  383. $(this).val("继续");
  384. }
  385. });
  386. $("#btnStop").click(function () {
  387. roamLine.stop();
  388. $("#btnPause").hide();
  389. });
  390. initUI();
  391. if (map.viewer.timeline) {
  392. map.viewer.timeline.zoomTo(roamLine.startTime, roamLine.stopTime);
  393. }
  394. //显示基本信息,名称、总长、总时间
  395. showAllInfo({
  396. name: roamLine.name,
  397. alllen: roamLine.alllen,
  398. alltime: roamLine.alltimes,
  399. });
  400. roamLine.on(mars3d.EventType.change, (event) => {
  401. //面板显示相关信息
  402. showRealTimeInfo(event);
  403. });
  404. }
  405. function initUI() {
  406. $("#cameraType").attr("data-value", roamLine.options.camera.type);
  407. $("#followedX").val(roamLine.options.camera.followedX);
  408. $("#followedZ").val(roamLine.options.camera.followedZ);
  409. $("#offsetZ").val(roamLine.options.camera.offsetZ || 0);
  410. $("#offsetY").val(roamLine.options.camera.offsetY || 0);
  411. $("#offsetX").val(roamLine.options.camera.offsetX || 0);
  412. //改变视角模式
  413. $("#cameraType").select(); //绑定样式
  414. $("#cameraType").change(function () {
  415. $("#tr_followedX").hide();
  416. $("#tr_followedZ").hide();
  417. var attrVal = $(this).attr("data-value");
  418. switch (attrVal) {
  419. default:
  420. break;
  421. case "gs": //
  422. $("#tr_followedX").show();
  423. break;
  424. case "dy": //锁定第一视角
  425. $("#tr_followedX").show();
  426. $("#tr_followedZ").show();
  427. $("#followedX").val(200);
  428. $("#followedZ").val(50);
  429. $("#offsetZ").val(0);
  430. $("#offsetY").val(0);
  431. $("#offsetX").val(0);
  432. break;
  433. case "sd": //锁定上帝视角
  434. $("#tr_followedZ").show();
  435. var followedZ = Number($("#followedZ").val());
  436. if (followedZ < 500) {
  437. $("#followedZ").val(500);
  438. }
  439. break;
  440. }
  441. updateCameraSetting();
  442. });
  443. $("#cameraType").change();
  444. //第一视角
  445. $("#followedX").change(function () {
  446. updateCameraSetting();
  447. });
  448. $("#followedZ").change(function () {
  449. updateCameraSetting();
  450. });
  451. $("#offsetY").change(function () {
  452. updateCameraSetting();
  453. });
  454. $("#offsetZ").change(function () {
  455. updateCameraSetting();
  456. });
  457. $("#offsetX").change(function () {
  458. updateCameraSetting();
  459. });
  460. //模型方向
  461. $(".jiaodu_2_angele").hide();
  462. $('input:radio[name="jiaodu"]').change(function () {
  463. var isAuto = $(this).val() === "1";
  464. if (isAuto) {
  465. $(".jiaodu_2_angele").hide();
  466. } else {
  467. $(".jiaodu_2_angele").show();
  468. }
  469. updateModel(isAuto);
  470. });
  471. //滑动条
  472. $("#model_pitch")
  473. .slider({ min: 0, max: 360, step: 0.01, value: 0 })
  474. .on("change", (e) => {
  475. updateModel();
  476. });
  477. $("#model_roll")
  478. .slider({ min: 0, max: 360, step: 0.01, value: 0 })
  479. .on("change", (e) => {
  480. updateModel();
  481. });
  482. }
  483. function updateModel(isAuto) {
  484. var pitch = Number($("#model_pitch").val());
  485. var roll = Number($("#model_roll").val());
  486. roamLine.updateAngle(isAuto, {
  487. pitch: pitch,
  488. roll: roll,
  489. });
  490. }
  491. //改变视角模式
  492. function updateCameraSetting() {
  493. var cameraType = $("#cameraType").attr("data-value");
  494. var followedX = Number($("#followedX").val());
  495. var followedZ = Number($("#followedZ").val());
  496. var offsetZ = Number($("#offsetZ").val());
  497. var offsetY = Number($("#offsetY").val());
  498. var offsetX = Number($("#offsetX").val());
  499. roamLine.setCameraOptions({
  500. type: cameraType,
  501. radius: cameraType == "gs" ? followedX : 0,
  502. followedX: followedX,
  503. followedZ: followedZ,
  504. offsetZ: offsetZ,
  505. offsetY: offsetY,
  506. offsetX: offsetX,
  507. });
  508. }
  509. //显示基本信息,名称、总长、总时间
  510. var _alltime = 100;
  511. function showAllInfo(params) {
  512. _alltime = params.alltime;
  513. $("#td_alltimes").html(haoutil.str.formatTime(params.alltime));
  514. $("#td_alllength").html(haoutil.str.formatLength(params.alllen));
  515. }
  516. //显示实时坐标和时间
  517. function showRealTimeInfo(params) {
  518. if (params == null) {
  519. return;
  520. }
  521. var val = Math.ceil((params.time * 100) / _alltime);
  522. if (val < 1) {
  523. val = 1;
  524. }
  525. if (val > 100) {
  526. val = 100;
  527. }
  528. $(".progress-bar")
  529. .css("width", val + "%")
  530. .attr("aria-valuenow", val)
  531. .html(val + "%");
  532. $("#td_jd").html(params.lng);
  533. $("#td_wd").html(params.lat);
  534. $("#td_gd").html(haoutil.str.formatLength(params.alt));
  535. $("#td_times").html(haoutil.str.formatTime(params.time));
  536. $("#td_length").html(haoutil.str.formatLength(params.len));
  537. if (params.hbgd) {
  538. $("#td_dmhb").html(haoutil.str.formatLength(params.hbgd));
  539. } else {
  540. $("#td_dmhb").html("未知");
  541. }
  542. if (params.ldgd) {
  543. $("#td_ldgd").html(haoutil.str.formatLength(params.ldgd));
  544. } else {
  545. $("#td_ldgd").html("未知");
  546. }
  547. }
  548. </script>
  549. </body>
  550. </html>