f65_roamLine_indoor.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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,layer,haoutil,turf,mars3d"
  27. ></script>
  28. <link href="css/style.css" rel="stylesheet" />
  29. </head>
  30. <body class="dark">
  31. <!--加载前进行操作提示,优化用户体验-->
  32. <div id="mask" class="signmask" onclick="removeMask()"></div>
  33. <div id="mars3dContainer" class="mars3d-container"></div>
  34. <!-- 面板 -->
  35. <div class="infoview">
  36. <input type="button" class="btn btn-primary" value="开始漫游" onclick="startFly()" />
  37. <input type="button" class="btn btn-primary" value="停止漫游" onclick="stopFly()" />
  38. 其他室内视角:
  39. <input type="button" class="btn btn-primary" value="教室" onclick="centerAtDX1()" />
  40. <input type="button" class="btn btn-primary" value="走廊" onclick="centerAtDX2()" />
  41. <input type="button" class="btn btn-primary" value="楼梯间" onclick="centerAtDX3()" />
  42. </div>
  43. <script src="./js/common.js"></script>
  44. <script type="text/javascript">
  45. "use script"; //开发环境建议开启严格模式
  46. var map;
  47. var roamLine;
  48. function initMap(options) {
  49. //合并属性参数,可覆盖config.json中的对应配置
  50. var mapOptions = mars3d.Util.merge(options, {
  51. scene: {
  52. center: { lat: 31.843773, lng: 117.251509, alt: 34, heading: 270, pitch: -11 },
  53. },
  54. control: {
  55. animation: true, //是否创建动画小器件,左下角仪表
  56. timeline: true, //是否显示时间线控件
  57. infoBox: false,
  58. },
  59. layers: [
  60. {
  61. name: "教学楼",
  62. type: "3dtiles",
  63. url: "//data.mars3d.cn/3dtiles/bim-daxue/tileset.json",
  64. position: { lng: 117.251229, lat: 31.844015, alt: 31.2 },
  65. maximumScreenSpaceError: 8,
  66. maximumMemoryUsage: 1024,
  67. show: true,
  68. },
  69. ],
  70. });
  71. //创建三维地球场景
  72. map = new mars3d.Map("mars3dContainer", mapOptions);
  73. //键盘漫游
  74. map.keyboardRoam.setOptions({
  75. moveStep: 0.1, //平移步长 (米)。
  76. dirStep: 50, //相机原地旋转步长,值越大步长越小。
  77. rotateStep: 0.3, //相机围绕目标点旋转速率,0.3-2.0
  78. minPitch: 0.1, //最小仰角 0-1
  79. maxPitch: 0.95, //最大仰角 0-1
  80. });
  81. map.keyboardRoam.enabled = true; //开启键盘漫游
  82. //创建矢量数据图层
  83. var graphicLayer = new mars3d.layer.GraphicLayer();
  84. map.addLayer(graphicLayer);
  85. //该数据可以从 基础项目 飞行漫游功能界面操作后单个路线的 保存JSON
  86. var flydata = {
  87. name: "室内路线",
  88. speed: 5,
  89. positions: [
  90. [117.25164, 31.843773, 32.0],
  91. [117.251042, 31.843772, 32.0],
  92. [117.250613, 31.844058, 32.0],
  93. [117.250677, 31.844146, 32.0],
  94. [117.250696, 31.844134, 32.0],
  95. [117.250657, 31.844098, 36.0],
  96. [117.250611, 31.84406, 36.0],
  97. [117.251039, 31.843773, 36.0],
  98. ],
  99. camera: {
  100. type: "dy",
  101. followedX: 1,
  102. followedZ: 0.2,
  103. },
  104. offsetHeight: 1.6,
  105. };
  106. roamLine = new mars3d.graphic.RoamLine(flydata);
  107. graphicLayer.addGraphic(roamLine);
  108. startFly();
  109. }
  110. function startFly() {
  111. //启动漫游
  112. roamLine.start();
  113. }
  114. function stopFly() {
  115. roamLine.stop();
  116. haoutil.msg("请鼠标单击地图任意区域后,您再可以键盘按A S D W Q E键控制前后左右, 上下左右键控制旋转, 进行手动漫游。");
  117. }
  118. function centerAtDX1() {
  119. stopFly();
  120. map.setCameraView({ lat: 31.843703, lng: 117.251038, alt: 33, heading: 50, pitch: -6 });
  121. }
  122. function centerAtDX2() {
  123. stopFly();
  124. map.setCameraView({ lat: 31.843816, lng: 117.250978, alt: 34, heading: 308, pitch: -8 });
  125. }
  126. function centerAtDX3() {
  127. stopFly();
  128. map.setCameraView({ lat: 31.843789, lng: 117.251188, alt: 42, heading: 6, pitch: -31 });
  129. }
  130. </script>
  131. </body>
  132. </html>