f10_entity_plane.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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>Plane 平面 </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. </head>
  28. <body class="dark">
  29. <!--加载前进行操作提示,优化用户体验-->
  30. <div id="mask" class="signmask" onclick="removeMask()"></div>
  31. <div id="mars3dContainer" class="mars3d-container"></div>
  32. <div class="infoview">
  33. <div>
  34. 图层状态:
  35. <div class="checkbox checkbox-primary checkbox-inline">
  36. <input id="chkShow" class="styled" type="checkbox" checked />
  37. <label for="chkShow"> 显示隐藏 </label>
  38. </div>
  39. <div class="checkbox checkbox-primary checkbox-inline">
  40. <input id="chkPopup" class="styled" type="checkbox" checked />
  41. <label for="chkPopup"> Popup绑定 </label>
  42. </div>
  43. <div class="checkbox checkbox-primary checkbox-inline">
  44. <input id="chkTooltip" class="styled" type="checkbox" />
  45. <label for="chkTooltip"> Tooltip绑定 </label>
  46. </div>
  47. <div class="checkbox checkbox-primary checkbox-inline">
  48. <input id="chkContextMenu" class="styled" type="checkbox" checked />
  49. <label for="chkContextMenu"> 右键菜单绑定 </label>
  50. </div>
  51. </div>
  52. <div>
  53. 数据维护:
  54. <input id="btnStartDraw" type="button" class="btn btn-primary" value="图上标绘" title="在图上绘制新增一个矢量数据" />
  55. <div class="checkbox checkbox-primary checkbox-inline">
  56. <input id="chkHasEdit" class="styled" type="checkbox" />
  57. <label for="chkHasEdit"> 是否编辑 </label>
  58. </div>
  59. </div>
  60. <div>
  61. 数据管理:
  62. <input id="btnClear" type="button" class="btn btn-danger" value="清除" />
  63. <input id="btnExpFile" type="button" class="btn btn-primary" value="保存GeoJSON" title="保存为GeoJSON文件" />
  64. <input id="btnImpFile" type="button" class="btn btn-primary" value="打开GeoJSON" title="打开之前保存的GeoJSON文件" />
  65. <input id="input_draw_file" type="file" accept=".json,.geojson" style="display: none" />
  66. </div>
  67. </div>
  68. <!-- 切换视角到模型或地形(山区)的快捷按钮 -->
  69. <script type="text/javascript" src="js/center_terrain_3dtiles.js"></script>
  70. <!-- 图层管理相关处理js -->
  71. <script type="text/javascript" src="./js/graphicManager.js"></script>
  72. <script src="./js/common.js"></script>
  73. <script type="text/javascript">
  74. "use script"; //开发环境建议开启严格模式
  75. var map;
  76. function initMap(options) {
  77. //合并属性参数,可覆盖config.json中的对应配置
  78. var mapOptions = mars3d.Util.merge(options, {});
  79. //创建三维地球场景
  80. map = new mars3d.Map("mars3dContainer", mapOptions);
  81. //创建矢量数据图层
  82. var graphicLayer = new mars3d.layer.GraphicLayer();
  83. map.addLayer(graphicLayer);
  84. //图层管理的相关处理,代码在\js\graphicManager.js
  85. initLayerManager(graphicLayer);
  86. $("#btnStartDraw").click(function () {
  87. //开始绘制
  88. graphicLayer.startDraw({
  89. type: "plane",
  90. style: {
  91. color: "#00ff00",
  92. opacity: 0.8,
  93. plane_normal: "x",
  94. dimensions_x: 1000.0,
  95. dimensions_y: 1000.0,
  96. },
  97. success: function (graphic) {
  98. console.log("绘制完成", graphic);
  99. },
  100. });
  101. });
  102. //加一些演示数据
  103. addGraphic_01(graphicLayer);
  104. addGraphic_02(graphicLayer);
  105. addGraphic_03(graphicLayer);
  106. addGraphic_04(graphicLayer);
  107. }
  108. function addGraphic_01(graphicLayer) {
  109. var graphic = new mars3d.graphic.PlaneEntity({
  110. position: [116.282587, 30.859197, 544.31],
  111. style: {
  112. plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Y, 0.0),
  113. dimensions_x: 2000.0,
  114. dimensions_y: 1000.0,
  115. color: "#00ff00",
  116. opacity: 0.4,
  117. //高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用
  118. highlight: {
  119. opacity: 0.9,
  120. },
  121. },
  122. });
  123. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  124. //演示个性化处理graphic,代码在\js\graphicManager.js
  125. initGraphicManager(graphic);
  126. }
  127. //
  128. function addGraphic_02(graphicLayer) {
  129. var graphic = new mars3d.graphic.PlaneEntity({
  130. position: new mars3d.LatLngPoint(116.329199, 30.881595, 390.3),
  131. style: {
  132. plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),
  133. dimensions: new Cesium.Cartesian2(1000.0, 1000.0),
  134. material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.Image, {
  135. image: "img/textures/movingRiver.png",
  136. transparent: true,
  137. }),
  138. },
  139. });
  140. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  141. //绑定Tooltip
  142. graphic.bindTooltip("我是graphic上绑定的Tooltip");
  143. }
  144. //
  145. function addGraphic_03(graphicLayer) {
  146. var graphic = new mars3d.graphic.PlaneEntity({
  147. position: new mars3d.LatLngPoint(116.392526, 30.903729, 933.55),
  148. style: {
  149. plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),
  150. dimensions: new Cesium.Cartesian2(1000.0, 1000.0),
  151. color: "rgba(255,0,0,0.5)",
  152. outline: true,
  153. outlineColor: "#ffff00",
  154. heading: 45,
  155. roll: 45,
  156. pitch: 0,
  157. },
  158. });
  159. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  160. }
  161. //
  162. function addGraphic_04(graphicLayer) {
  163. var graphic = new mars3d.graphic.PlaneEntity({
  164. position: [116.244399, 30.920459, 573.6],
  165. style: {
  166. plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_X, 0.0),
  167. dimensions: new Cesium.Cartesian2(1000.0, 1000.0),
  168. color: "#00ffff",
  169. opacity: 0.6,
  170. outline: true,
  171. outlineColor: "#000000",
  172. label: {
  173. text: "我是原始的",
  174. font_size: 18,
  175. color: "#ffffff",
  176. pixelOffsetY: -10,
  177. distanceDisplayCondition: true,
  178. distanceDisplayCondition_far: 500000,
  179. distanceDisplayCondition_near: 0,
  180. },
  181. },
  182. });
  183. graphicLayer.addGraphic(graphic);
  184. //entity转geojson
  185. var geojson = graphic.toGeoJSON();
  186. console.log(geojson);
  187. addGeoJson(geojson, graphicLayer);
  188. }
  189. //添加单个geojson为graphic,多个直接用graphicLayer.loadGeoJSON
  190. function addGeoJson(geojson, graphicLayer) {
  191. var graphicCopy = mars3d.Util.geoJsonToGraphics(geojson)[0];
  192. delete graphicCopy.attr;
  193. //新的坐标
  194. graphicCopy.position = [116.301991, 30.933872, 624.03];
  195. graphicCopy.style.label = graphicCopy.style.label || {};
  196. graphicCopy.style.label.text = "我是转换后生成的";
  197. graphicLayer.addGraphic(graphicCopy);
  198. }
  199. </script>
  200. </body>
  201. </html>