f16_coneTrack.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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,mars3d-space"
  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 id="btnSelPoint" type="button" class="btn btn-primary" value="追踪目标点" />
  37. </div>
  38. <!-- 图层管理相关处理js -->
  39. <script type="text/javascript" src="./js/graphicManager.js"></script>
  40. <script src="./js/common.js"></script>
  41. <script type="text/javascript">
  42. "use script"; //开发环境建议开启严格模式
  43. var map;
  44. function initMap(options) {
  45. //合并属性参数,可覆盖config.json中的对应配置
  46. var mapOptions = mars3d.Util.merge(options, {
  47. scene: {
  48. center: { lat: 30.808137, lng: 116.411699, alt: 23221, heading: 347, pitch: -40 },
  49. clock: {
  50. currentTime: "2021-07-01 10:45:00",
  51. },
  52. },
  53. });
  54. //创建三维地球场景
  55. map = new mars3d.Map("mars3dContainer", mapOptions);
  56. //创建矢量数据图层
  57. var graphicLayer = new mars3d.layer.GraphicLayer();
  58. map.addLayer(graphicLayer);
  59. //图层管理的相关处理,代码在\js\graphicManager.js
  60. initLayerManager(graphicLayer);
  61. //加一些演示数据
  62. addGraphic_01(graphicLayer);
  63. addGraphic_02(graphicLayer);
  64. addGraphic_03(graphicLayer);
  65. addGraphic_04(graphicLayer);
  66. }
  67. //静态的位置
  68. function addGraphic_01(graphicLayer) {
  69. var coneTrack = new mars3d.graphic.ConeTrack({
  70. position: [116.327881, 31.018378, 5000],
  71. targetPosition: [116.311135, 30.998408, 1264.9], //可选
  72. style: {
  73. slices: 4, //四凌锥
  74. // length: 4000,//targetPosition存在时无需传
  75. angle: 5, //半场角度
  76. color: "#ff0000",
  77. opacity: 0.3,
  78. label: { text: "鼠标移入会高亮" },
  79. //高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用
  80. highlight: {
  81. opacity: 0.8,
  82. },
  83. },
  84. });
  85. graphicLayer.addGraphic(coneTrack);
  86. }
  87. //静态的位置
  88. function addGraphic_02(graphicLayer) {
  89. let position = [116.28782, 30.971557, 5000];
  90. //加个飞机
  91. var primitive = new mars3d.graphic.ModelPrimitive({
  92. position: position,
  93. style: {
  94. url: "//data.mars3d.cn/gltf/mars/feiji.glb",
  95. scale: 1,
  96. minimumPixelSize: 50,
  97. },
  98. });
  99. graphicLayer.addGraphic(primitive);
  100. //圆锥追踪体
  101. var coneTrack = new mars3d.graphic.ConeTrack({
  102. position: position,
  103. // targetPosition: [116.317411, 30.972581, 1439.7], //可选
  104. style: {
  105. length: 4000,
  106. angle: 5, //半场角度
  107. material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.CircleWave, {
  108. duration: 2000,
  109. color: "#02ff00",
  110. }),
  111. },
  112. });
  113. graphicLayer.addGraphic(coneTrack);
  114. $("#btnSelPoint").click(function () {
  115. map.graphicLayer.startDraw({
  116. type: "point",
  117. style: {
  118. pixelSize: 8,
  119. color: "#ffff00",
  120. },
  121. success: function (graphic) {
  122. var position = graphic.positionShow;
  123. map.graphicLayer.clear();
  124. coneTrack.targetPosition = position;
  125. },
  126. });
  127. });
  128. }
  129. //动态的位置
  130. function addGraphic_03(graphicLayer) {
  131. let propertyFJ = getSampledPositionProperty([
  132. [116.364307, 31.03778, 5000],
  133. [116.42794, 31.064786, 5000],
  134. [116.474002, 31.003825, 5000],
  135. [116.432393, 30.951142, 5000],
  136. [116.368497, 30.969006, 5000],
  137. [116.364307, 31.03778, 5000],
  138. ]);
  139. //飞机
  140. var graphicModel = new mars3d.graphic.ModelEntity({
  141. position: propertyFJ,
  142. orientation: new Cesium.VelocityOrientationProperty(propertyFJ),
  143. style: {
  144. url: "//data.mars3d.cn/gltf/mars/zhanji.glb",
  145. scale: 0.3,
  146. minimumPixelSize: 30,
  147. },
  148. });
  149. graphicLayer.addGraphic(graphicModel);
  150. //汽车
  151. let propertyQC = getSampledPositionProperty([
  152. [116.391268, 30.956038, 827.2],
  153. [116.37934, 30.980835, 898.1],
  154. [116.382514, 30.999031, 921.5],
  155. [116.40338, 31.009258, 1214],
  156. [116.412254, 31.021635, 1224.1],
  157. [116.432328, 31.045508, 804.3],
  158. ]);
  159. var graphicQC = new mars3d.graphic.PathEntity({
  160. position: propertyQC,
  161. orientation: new Cesium.VelocityOrientationProperty(propertyQC),
  162. style: {
  163. width: 1,
  164. color: "#ffff00",
  165. opacity: 0.4,
  166. leadTime: 0,
  167. },
  168. model: {
  169. url: "//data.mars3d.cn/gltf/mars/qiche.gltf",
  170. scale: 0.5,
  171. minimumPixelSize: 50,
  172. },
  173. });
  174. graphicLayer.addGraphic(graphicQC);
  175. //圆锥追踪体(动态position=>动态targetPosition)
  176. var coneTrack = new mars3d.graphic.ConeTrack({
  177. position: propertyFJ,
  178. targetPosition: propertyQC,
  179. style: {
  180. // length: 4000, //targetPosition存在时无需传
  181. angle: 1, //半场角度
  182. color: "#00ffff",
  183. opacity: 0.4,
  184. },
  185. });
  186. graphicLayer.addGraphic(coneTrack);
  187. }
  188. //计算演示的SampledPositionProperty轨迹
  189. function getSampledPositionProperty(points) {
  190. let property = new Cesium.SampledPositionProperty();
  191. let start = map.clock.currentTime;
  192. let positions = mars3d.LatLngArray.toCartesians(points);
  193. for (let i = 0; i < positions.length; i++) {
  194. let time = Cesium.JulianDate.addSeconds(start, i * 20, new Cesium.JulianDate());
  195. let position = positions[i];
  196. property.addSample(time, position);
  197. }
  198. return property;
  199. }
  200. //
  201. function addGraphic_04(graphicLayer) {
  202. var model = new mars3d.graphic.ModelEntity({
  203. name: "地面站模型",
  204. position: [117.170264, 31.840312, 258],
  205. style: {
  206. url: "//data.mars3d.cn/gltf/mars/leida.glb",
  207. scale: 1,
  208. minimumPixelSize: 40,
  209. clampToGround: true,
  210. },
  211. });
  212. graphicLayer.addGraphic(model);
  213. //卫星
  214. var weixin = new mars3d.graphic.Satellite({
  215. name: "GAOFEN 1",
  216. tle1: "1 39150U 13018A 21180.50843864 .00000088 00000-0 19781-4 0 9997",
  217. tle2: "2 39150 97.8300 252.9072 0018449 344.7422 15.3253 14.76581022440650",
  218. model: {
  219. url: "//data.mars3d.cn/gltf/mars/weixin.gltf",
  220. scale: 1,
  221. minimumPixelSize: 90,
  222. autoHeading: true,
  223. show: true,
  224. },
  225. path: { color: "#00ff00", opacity: 0.5, width: 1, show: true },
  226. });
  227. graphicLayer.addGraphic(weixin);
  228. var coneTrack = new mars3d.graphic.ConeTrack({
  229. position: model.position,
  230. targetPosition: weixin.property,
  231. style: {
  232. angle: 1, //半场角度
  233. color: "#ff0000",
  234. opacity: 0.4,
  235. },
  236. });
  237. graphicLayer.addGraphic(coneTrack);
  238. }
  239. </script>
  240. </body>
  241. </html>