f40_divGraphic_hg.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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="apple-touch-fullscreen" content="yes" />
  7. <meta name="apple-mobile-web-app-capable" content="yes" />
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  9. <meta name="format-detection" content="telephone=no" />
  10. <meta name="x5-fullscreen" content="true" />
  11. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
  12. <!-- 标题及搜索关键字 -->
  13. <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
  14. <meta
  15. name="description"
  16. content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
  17. />
  18. <link rel="shortcut icon" type="image/x-icon" href="" />
  19. <title>油气站标注</title>
  20. <script
  21. type="text/javascript"
  22. src="../lib/include-lib.js"
  23. libpath="../lib/"
  24. include="jquery,font-awesome,bootstrap,bootstrap-checkbox,layer,haoutil,turf,mars3d"
  25. ></script>
  26. <link href="css/style.css" rel="stylesheet" />
  27. <link href="css/divGraphic.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. <div class="infoview initDivGraphic">
  34. 效果:
  35. <div class="btn-group" role="group">
  36. <input id="btnDivgraphicYellow" type="button" class="btn btn-primary active" value="效果一" />
  37. <input id="btnDivgraphicBule" type="button" class="btn btn-primary" value="效果二" />
  38. <input id="btnDivgraphicWhite" type="button" class="btn btn-primary" value="效果三" />
  39. </div>
  40. </div>
  41. <script src="./js/common.js"></script>
  42. <script type="text/javascript">
  43. "use script"; //开发环境建议开启严格模式
  44. var map;
  45. var graphicLayer;
  46. var arrData = [
  47. { name: "油罐一", position: [117.09521, 31.814404, 47.3] },
  48. { name: "油罐二", position: [117.095206, 31.814878, 47.3] },
  49. { name: "油罐三", position: [117.094653, 31.814428, 47.3] },
  50. { name: "发电机", position: [117.093428, 31.816959, 31.8] },
  51. { name: "指挥室", position: [117.093953, 31.814397, 36] },
  52. { name: "加热罐", position: [117.09385, 31.815837, 36.9] },
  53. { name: "冷却室", position: [117.094662, 31.816403, 32.9] },
  54. ];
  55. function initMap(options) {
  56. //合并属性参数,可覆盖config.json中的对应配置
  57. var mapOptions = mars3d.Util.merge(options, {
  58. scene: {
  59. center: { lat: 31.81226, lng: 117.096703, alt: 231, heading: 329, pitch: -28 },
  60. },
  61. });
  62. //创建三维地球场景
  63. map = new mars3d.Map("mars3dContainer", mapOptions);
  64. // 加载油田联合站模型
  65. let tiles3dLayer = new mars3d.layer.TilesetLayer({
  66. pid: 2020,
  67. type: "3dtiles",
  68. name: "油田联合站",
  69. url: "//data.mars3d.cn/3dtiles/max-ytlhz/tileset.json",
  70. position: { lng: 117.094224, lat: 31.815859, alt: 26.4 },
  71. rotation: { z: 116.2 },
  72. maximumScreenSpaceError: 1,
  73. center: { lat: 32.407076, lng: 117.459703, alt: 3361, heading: 358, pitch: -51 },
  74. });
  75. map.addLayer(tiles3dLayer);
  76. //创建DIV数据图层
  77. graphicLayer = new mars3d.layer.DivLayer();
  78. map.addLayer(graphicLayer);
  79. // 初始加载
  80. divGraphicYellow();
  81. // 按钮切换效果
  82. $("#btnDivgraphicYellow").click(function () {
  83. $(".active").removeClass("active");
  84. $(this).addClass("active");
  85. divGraphicYellow();
  86. });
  87. $("#btnDivgraphicBule").click(function () {
  88. $(".active").removeClass("active");
  89. $(this).addClass("active");
  90. divGraphicBule();
  91. });
  92. $("#btnDivgraphicWhite").click(function () {
  93. $(".active").removeClass("active");
  94. $(this).addClass("active");
  95. divGraphicWhite();
  96. });
  97. // 效果一
  98. function divGraphicYellow() {
  99. graphicLayer.clear();
  100. for (let i = 0; i < arrData.length; i++) {
  101. let item = arrData[i];
  102. var divGraphic = new mars3d.graphic.DivGraphic({
  103. position: item.position,
  104. style: {
  105. html: `<div class="marsBlackPanel animation-spaceInDown">
  106. <div class="marsBlackPanel-text" style="">
  107. ${item.name} <span class="temperature"></span> ℃
  108. </div>
  109. </div>`,
  110. horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
  111. verticalOrigin: Cesium.VerticalOrigin.CENTER,
  112. },
  113. attr: {
  114. index: i + 1,
  115. duNum: 0,
  116. },
  117. });
  118. graphicLayer.addGraphic(divGraphic);
  119. //刷新局部DOM,不影响popup面板的其他控件操作
  120. divGraphic.on(mars3d.EventType.postRender, function (event) {
  121. let container = event.container; //popup对应的DOM
  122. let graphic = event.target;
  123. let oldVal = graphic.attr.duNum;
  124. let newVal = Number(new Date().format("ss")) + graphic.attr.index;
  125. if (oldVal !== newVal) {
  126. graphic.attr.duNum = newVal;
  127. let temperatureDom = container.querySelector(".temperature");
  128. if (temperatureDom) {
  129. temperatureDom.innerHTML = newVal;
  130. }
  131. }
  132. });
  133. }
  134. }
  135. // 效果二
  136. function divGraphicBule() {
  137. graphicLayer.clear();
  138. for (let i = 0; i < arrData.length; i++) {
  139. let item = arrData[i];
  140. var divGraphic = new mars3d.graphic.DivGraphic({
  141. position: item.position,
  142. style: {
  143. html: `<div class="marsBlueGradientPnl">
  144. <div>${item.name}</div>
  145. </div>`,
  146. offsetY: -60,
  147. horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  148. verticalOrigin: Cesium.VerticalOrigin.BTOOM,
  149. },
  150. });
  151. graphicLayer.addGraphic(divGraphic);
  152. }
  153. }
  154. // 效果三
  155. function divGraphicWhite() {
  156. graphicLayer.clear();
  157. for (let i = 0; i < arrData.length; i++) {
  158. let item = arrData[i];
  159. var divGraphic = new mars3d.graphic.DivUpLabel({
  160. position: item.position,
  161. style: {
  162. text: item.name,
  163. color: "#fff",
  164. font_size: 16,
  165. font_family: "微软雅黑",
  166. lineHeight: 50,
  167. circleSize: 8,
  168. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 100000), //按视距距离显示
  169. },
  170. });
  171. graphicLayer.addGraphic(divGraphic);
  172. }
  173. }
  174. }
  175. </script>
  176. </body>
  177. </html>