f45_flypath2.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!-- 2017-12-4 14:24:11 | 修改 木遥(微信: 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,layer,haoutil,turf,mars3d"
  26. ></script>
  27. <link href="css/style.css" rel="stylesheet" />
  28. </head>
  29. <body class="dark">
  30. <!--加载前进行操作提示,优化用户体验-->
  31. <div id="mask" class="signmask" onclick="removeMask()"></div>
  32. <div id="mars3dContainer" class="mars3d-container"></div>
  33. <!-- 面板 -->
  34. <div class="infoview">
  35. <input id="btnSeeTop" type="button" class="btn btn-primary" value="顶视图" />
  36. <input id="btnSeeCe" type="button" class="btn btn-primary" value="侧视图" />
  37. <input id="btnSeeHome" type="button" class="btn btn-primary" value="主视图" />
  38. </div>
  39. <script src="./js/common.js"></script>
  40. <script type="text/javascript">
  41. "use script"; //开发环境建议开启严格模式
  42. var map;
  43. function initMap(options) {
  44. //合并属性参数,可覆盖config.json中的对应配置
  45. var mapOptions = mars3d.Util.merge(options, {
  46. scene: {
  47. center: { lat: 20.803452, lng: 116.629014, alt: 1734203, heading: 3, pitch: -57 },
  48. },
  49. });
  50. //创建三维地球场景
  51. map = new mars3d.Map("mars3dContainer", mapOptions);
  52. //创建矢量数据图层
  53. let graphicLayer = new mars3d.layer.GraphicLayer();
  54. map.addLayer(graphicLayer);
  55. //半球
  56. var graphicQiu = new mars3d.graphic.EllipsoidEntity({
  57. position: new mars3d.LatLngPoint(117.276726, 31.864175, -10000.0),
  58. style: {
  59. radii: new Cesium.Cartesian3(200000.0, 200000.0, 200000.0),
  60. maximumConeDegree: 90,
  61. material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.EllipsoidWave, {
  62. color: "#ff0000",
  63. speed: 5.0,
  64. }),
  65. outline: false,
  66. },
  67. });
  68. graphicLayer.addGraphic(graphicQiu);
  69. //计算圆圈线
  70. var linePositions = mars3d.PolyUtil.getEllipseOuterPositions({
  71. position: Cesium.Cartesian3.fromDegrees(117.276726, 31.864175),
  72. radius: 500000,
  73. count: 60, //共返回count*4个点
  74. });
  75. linePositions = mars3d.PointUtil.setPositionsHeight(linePositions, 100000);
  76. linePositions.push(linePositions[0]); //闭合圆
  77. //圆圈线
  78. // let graphicLine = new mars3d.graphic.PolylineEntity({
  79. // positions: linePositions,
  80. // style: {
  81. // width: 8,
  82. // material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.PolylineGlow, {
  83. // glowPower: 0.2,
  84. // color: Cesium.Color.GREEN,
  85. // }),
  86. // },
  87. // });
  88. // graphicLayer.addGraphic(graphicLine);
  89. //飞机path路径
  90. var property = new Cesium.SampledPositionProperty();
  91. var start = map.clock.currentTime;
  92. var alltimes = 0;
  93. for (var i = 0, len = linePositions.length; i < len; i++) {
  94. alltimes += 1;
  95. let time = Cesium.JulianDate.addSeconds(start, alltimes, new Cesium.JulianDate());
  96. property.addSample(time, linePositions[i]);
  97. }
  98. let stop = Cesium.JulianDate.addSeconds(start, alltimes, new Cesium.JulianDate());
  99. // This is where it becomes a smooth path.
  100. property.setInterpolationOptions({
  101. interpolationDegree: 5,
  102. interpolationAlgorithm: Cesium.LagrangePolynomialApproximation,
  103. });
  104. var graphicPath = new mars3d.graphic.PathEntity({
  105. position: property,
  106. orientation: new Cesium.VelocityOrientationProperty(property),
  107. style: {
  108. width: 2,
  109. color: "#ffff00",
  110. opacity: 0.9,
  111. },
  112. label: {
  113. text: "火星1号",
  114. font_size: 19,
  115. font_family: "楷体",
  116. color: Cesium.Color.AZURE,
  117. outline: true,
  118. outlineColor: Cesium.Color.BLACK,
  119. outlineWidth: 2,
  120. horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  121. verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
  122. pixelOffset: new Cesium.Cartesian2(10, -25), //偏移量
  123. },
  124. model: {
  125. url: "//data.mars3d.cn/gltf/mars/zhanji.glb",
  126. scale: 0.1,
  127. minimumPixelSize: 90,
  128. },
  129. });
  130. graphicLayer.addGraphic(graphicPath);
  131. //Make sure viewer is at the desired time.
  132. map.clock.startTime = start.clone();
  133. map.clock.stopTime = stop.clone();
  134. map.clock.currentTime = start.clone();
  135. map.clock.clockRange = Cesium.ClockRange.LOOP_STOP; //到达终止时间后循环
  136. map.clock.multiplier = 1;
  137. map.clock.shouldAnimate = true;
  138. $("#btnSeeTop").click(function () {
  139. //顶视图
  140. map.trackedEntity = undefined;
  141. map.flyToPositions(linePositions, { pitch: -90 });
  142. });
  143. $("#btnSeeCe").click(function () {
  144. //侧视图
  145. map.trackedEntity = graphicPath.entity;
  146. graphicPath.flyToPoint({
  147. radius: 50000,
  148. heading: 0,
  149. });
  150. });
  151. $("#btnSeeHome").click(function () {
  152. //主视图
  153. map.trackedEntity = graphicPath.entity;
  154. graphicPath.flyToPoint({
  155. radius: 50000,
  156. heading: 90,
  157. });
  158. });
  159. }
  160. </script>
  161. </body>
  162. </html>