d15_keyboardRoam.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  6. <meta name="author" content="火星科技 http://mars3d.cn " />
  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. <!--第三方lib-->
  22. <script
  23. type="text/javascript"
  24. src="../lib/include-lib.js"
  25. libpath="../lib/"
  26. include="jquery,font-awesome,bootstrap,bootstrap-checkbox,bootstrap-slider,layer,haoutil,turf,mars3d"
  27. ></script>
  28. <link href="css/style.css" rel="stylesheet" />
  29. <style>
  30. .slider.slider-horizontal {
  31. width: 125px;
  32. height: 20px;
  33. margin-left: 3px;
  34. }
  35. </style>
  36. </head>
  37. <body class="dark">
  38. <!--加载前进行操作提示,优化用户体验-->
  39. <div id="mask" class="signmask" onclick="removeMask()"></div>
  40. <div id="mars3dContainer" class="mars3d-container"></div>
  41. <!-- 面板 -->
  42. <!-- 面板 -->
  43. <div class="infoview">
  44. <table class="mars-table">
  45. <tr>
  46. <td class="nametd">相机平移:</td>
  47. <td>W :向前</td>
  48. <td>S :向后</td>
  49. <td>D :向右</td>
  50. <td>A :向左</td>
  51. <td>Q :升高高度</td>
  52. <td>E :降低高度</td>
  53. <td title="平移的步长(单位:米)">
  54. 步长:
  55. <input id="txtStep" />
  56. </td>
  57. </tr>
  58. <tr>
  59. <td class="nametd">相对于相机本身:</td>
  60. <td>↑ :抬头</td>
  61. <td>↓ :低头</td>
  62. <td>← :向左旋转</td>
  63. <td>→ :向右旋转</td>
  64. <td></td>
  65. <td></td>
  66. </tr>
  67. <tr>
  68. <td class="nametd">相对于屏幕中心点:</td>
  69. <td>I :飞近</td>
  70. <td>K :远离</td>
  71. <td>J :逆时针旋转</td>
  72. <td>L :顺时针旋转</td>
  73. <td>U :向上旋转</td>
  74. <td>O :向下旋转</td>
  75. </tr>
  76. </table>
  77. <div>
  78. 演示视角:
  79. <input type="button" class="btn btn-primary" value="室内" onclick="centerAtDX1()" />
  80. <input type="button" class="btn btn-primary" value="室外" onclick="centerAtDX2()" />
  81. </div>
  82. </div>
  83. <script src="./js/common.js"></script>
  84. <script type="text/javascript">
  85. "use script"; //开发环境建议开启严格模式
  86. var map;
  87. function initMap(options) {
  88. //合并属性参数,可覆盖config.json中的对应配置
  89. var mapOptions = mars3d.Util.merge(options, {
  90. scene: {
  91. center: { lat: 31.840726, lng: 117.25174, alt: 206, heading: 357, pitch: -25 },
  92. cameraController: {
  93. enableCollisionDetection: false,
  94. },
  95. },
  96. control: {
  97. infoBox: false,
  98. },
  99. layers: [
  100. {
  101. id: 1987,
  102. name: "教学楼",
  103. type: "3dtiles",
  104. url: "//data.mars3d.cn/3dtiles/bim-daxue/tileset.json",
  105. position: { lng: 117.251229, lat: 31.844015, alt: 31.2 },
  106. maximumScreenSpaceError: 16,
  107. maximumMemoryUsage: 1024,
  108. show: true,
  109. },
  110. ],
  111. });
  112. //创建三维地球场景
  113. map = new mars3d.Map("mars3dContainer", mapOptions);
  114. //开启键盘漫游
  115. map.keyboardRoam.enabled = true;
  116. map.keyboardRoam.minHeight = 80;
  117. map.keyboardRoam.setOptions({
  118. moveStep: 10, //平移步长 (米)。
  119. dirStep: 25, //相机原地旋转步长,值越大步长越小。
  120. rotateStep: 1.0, //相机围绕目标点旋转速率,0.3-2.0
  121. minPitch: 0.1, //最小仰角 0-1
  122. maxPitch: 0.95, //最大仰角 0-1
  123. });
  124. //不按键一直自动往前走,调用stopMoveForward停止。
  125. // map.keyboardRoam.startMoveForward()
  126. //相机原地左一直旋转
  127. // setInterval(function () {
  128. // map.keyboardRoam.rotateCamera(mars3d.KeyboardType.LEFT_ROTATE);
  129. // }, 100);
  130. //滑动条
  131. $("#txtStep")
  132. .slider({
  133. min: 0.1,
  134. max: 300.0,
  135. step: 0.01,
  136. value: 10,
  137. })
  138. .on("change", (e) => {
  139. //修改步长
  140. if (e && e.value) {
  141. map.keyboardRoam.moveStep = e.value.newValue;
  142. }
  143. });
  144. }
  145. //室内
  146. function centerAtDX1() {
  147. map.keyboardRoam.moveStep = 0.1; //平移步长 (米)。
  148. map.keyboardRoam.dirStep = 50; //相机原地旋转步长,值越大步长越小。
  149. map.keyboardRoam.rotateStep = 0.3; //相机围绕目标点旋转速率,0.3-2.0
  150. map.setCameraView({ lat: 31.843804, lng: 117.250994, alt: 33, heading: 307, pitch: 1 });
  151. }
  152. //室外
  153. function centerAtDX2() {
  154. map.keyboardRoam.moveStep = 10; //平移步长 (米)。
  155. map.keyboardRoam.dirStep = 25; //相机原地旋转步长,值越大步长越小。
  156. map.keyboardRoam.rotateStep = 1.0; //相机围绕目标点旋转速率,0.3-2.0
  157. map.setCameraView({ lat: 31.829732, lng: 117.246797, alt: 773, heading: 357, pitch: -25 });
  158. }
  159. </script>
  160. </body>
  161. </html>