e10_graphicLayer.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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>graphic 数据图层 </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. <!-- 面板 -->
  33. <div class="infoview">
  34. <div>
  35. 图层状态:
  36. <div class="checkbox checkbox-primary checkbox-inline">
  37. <input id="chkShow" class="styled" type="checkbox" checked />
  38. <label for="chkShow"> 显示隐藏 </label>
  39. </div>
  40. <div class="checkbox checkbox-primary checkbox-inline">
  41. <input id="chkPopup" class="styled" type="checkbox" checked />
  42. <label for="chkPopup"> Popup绑定 </label>
  43. </div>
  44. <div class="checkbox checkbox-primary checkbox-inline">
  45. <input id="chkTooltip" class="styled" type="checkbox" />
  46. <label for="chkTooltip"> Tooltip绑定 </label>
  47. </div>
  48. <div class="checkbox checkbox-primary checkbox-inline">
  49. <input id="chkContextMenu" class="styled" type="checkbox" checked />
  50. <label for="chkContextMenu"> 右键菜单绑定 </label>
  51. </div>
  52. </div>
  53. <div>
  54. <span>点状(单个坐标):</span>
  55. <a href="editor.html#f10_entity_label" target="_blank" class="btn btn-default">文字</a>
  56. <a href="editor.html#f10_entity_point" target="_blank" class="btn btn-default">点</a>
  57. <a href="editor.html#f10_entity_billboard" target="_blank" class="btn btn-default">图标点</a>
  58. <a href="editor.html#f10_entity_plane" target="_blank" class="btn btn-default">平面</a>
  59. <a href="editor.html#f10_entity_box" target="_blank" class="btn btn-default">盒子</a>
  60. <a href="editor.html#f10_entity_circle" target="_blank" class="btn btn-default">圆</a>
  61. <a href="editor.html#f10_entity_cylinder" target="_blank" class="btn btn-default">圆锥</a>
  62. <a href="editor.html#f10_entity_ellipsoid" target="_blank" class="btn btn-default">球</a>
  63. <a href="editor.html#f10_entity_model" target="_blank" class="btn btn-default">小模型</a>
  64. </div>
  65. <div>
  66. <span>线面状(多个坐标):</span>
  67. <a href="editor.html#f15_entity_polyline" target="_blank" class="btn btn-default">线</a>
  68. <a href="editor.html#f15_entity_polylineVolume" target="_blank" class="btn btn-default">管道</a>
  69. <a href="editor.html#f15_entity_corridor" target="_blank" class="btn btn-default">走廊</a>
  70. <a href="editor.html#f15_entity_wall" target="_blank" class="btn btn-default">墙</a>
  71. <a href="editor.html#f15_entity_rectangle" target="_blank" class="btn btn-default">矩形</a>
  72. <a href="editor.html#f15_entity_polygon" target="_blank" class="btn btn-default">面</a>
  73. </div>
  74. </div>
  75. <!-- 图层管理相关处理js -->
  76. <script type="text/javascript" src="./js/graphicManager.js"></script>
  77. <script src="./js/common.js"></script>
  78. <script type="text/javascript">
  79. "use script"; //开发环境建议开启严格模式
  80. let map;
  81. function initMap(options) {
  82. //合并属性参数,可覆盖config.json中的对应配置
  83. let mapOptions = mars3d.Util.merge(options, {});
  84. //创建三维地球场景
  85. map = new mars3d.Map("mars3dContainer", mapOptions);
  86. //1.在map上绑定监听事件
  87. // map.on(mars3d.EventType.clickGraphic, function(event) {
  88. // //clickGraphic
  89. // console.log('监听map,单击了矢量对象', event)
  90. // })
  91. // map.on(mars3d.EventType.mouseMove, function(event) {
  92. // //mouseMove
  93. // console.log('监听map,鼠标移动了', event)
  94. // })
  95. //创建矢量数据图层
  96. let graphicLayer = new mars3d.layer.GraphicLayer();
  97. map.addLayer(graphicLayer);
  98. //图层管理的相关处理,代码在\js\graphicManager.js
  99. //2.在layer上绑定监听事件
  100. initLayerManager(graphicLayer);
  101. //加一些演示数据
  102. addGraphic_e01(graphicLayer);
  103. addGraphic_e02(graphicLayer);
  104. addGraphic_e03(graphicLayer);
  105. addGraphic_e04(graphicLayer);
  106. addGraphic_e05(graphicLayer);
  107. addGraphic_e06(graphicLayer);
  108. addGraphic_e07(graphicLayer);
  109. addGraphic_e08(graphicLayer);
  110. addGraphic_e09(graphicLayer);
  111. addGraphic_e10(graphicLayer);
  112. addGraphic_e11(graphicLayer);
  113. addGraphic_e12(graphicLayer);
  114. addGraphic_e13(graphicLayer);
  115. addGraphic_e14(graphicLayer);
  116. addGraphic_e15(graphicLayer);
  117. }
  118. function addGraphic_e01(graphicLayer) {
  119. let graphic = new mars3d.graphic.LabelEntity({
  120. position: new mars3d.LatLngPoint(116.1, 31.0, 1000),
  121. style: {
  122. text: "火星科技Mars3D平台",
  123. font_size: 25,
  124. font_family: "楷体",
  125. color: "#003da6",
  126. outline: true,
  127. outlineColor: "#bfbfbf",
  128. outlineWidth: 2,
  129. horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  130. verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
  131. visibleDepth: false,
  132. },
  133. });
  134. graphicLayer.addGraphic(graphic);
  135. }
  136. function addGraphic_e02(graphicLayer) {
  137. let graphic = new mars3d.graphic.PointEntity({
  138. position: [116.2, 31.0, 1000],
  139. style: {
  140. color: "#ff0000",
  141. pixelSize: 10,
  142. outline: true,
  143. outlineColor: "#ffffff",
  144. outlineWidth: 2,
  145. },
  146. });
  147. graphicLayer.addGraphic(graphic);
  148. }
  149. function addGraphic_e03(graphicLayer) {
  150. let graphic = new mars3d.graphic.BillboardEntity({
  151. name: "贴地图标",
  152. position: [116.3, 31.0, 1000],
  153. style: {
  154. image: "img/marker/mark2.png",
  155. scale: 1,
  156. horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  157. verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
  158. clampToGround: true,
  159. },
  160. });
  161. graphicLayer.addGraphic(graphic);
  162. }
  163. function addGraphic_e04(graphicLayer) {
  164. let graphic = new mars3d.graphic.PlaneEntity({
  165. position: new mars3d.LatLngPoint(116.4, 31.0, 1000),
  166. style: {
  167. plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),
  168. dimensions: new Cesium.Cartesian2(4000.0, 4000.0),
  169. material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.Image, {
  170. image: "img/textures/movingRiver.png",
  171. transparent: true,
  172. }),
  173. },
  174. });
  175. graphicLayer.addGraphic(graphic);
  176. }
  177. //
  178. function addGraphic_e05(graphicLayer) {
  179. let graphic = new mars3d.graphic.BoxEntity({
  180. position: new mars3d.LatLngPoint(116.5, 31.0, 1000),
  181. style: {
  182. dimensions: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  183. fill: true,
  184. color: "#00ffff",
  185. opacity: 0.9,
  186. heading: 45,
  187. roll: 45,
  188. pitch: 0,
  189. },
  190. });
  191. graphicLayer.addGraphic(graphic);
  192. }
  193. function addGraphic_e06(graphicLayer) {
  194. let graphic = new mars3d.graphic.CircleEntity({
  195. position: [116.1, 30.9, 1000],
  196. style: {
  197. radius: 1800.0,
  198. color: "#00ff00",
  199. opacity: 0.3,
  200. outline: true,
  201. outlineWidth: 3,
  202. outlineColor: "#ffffff",
  203. clampToGround: true,
  204. },
  205. popup: "直接传参的popup",
  206. });
  207. graphicLayer.addGraphic(graphic);
  208. }
  209. function addGraphic_e07(graphicLayer) {
  210. let graphic = new mars3d.graphic.CylinderEntity({
  211. position: [116.2, 30.9, 1000],
  212. style: {
  213. length: 3000.0,
  214. topRadius: 0.0,
  215. bottomRadius: 1300.0,
  216. color: "#00FFFF",
  217. opacity: 0.7,
  218. },
  219. popup: "直接传参的popup",
  220. });
  221. graphicLayer.addGraphic(graphic);
  222. }
  223. //
  224. function addGraphic_e08(graphicLayer) {
  225. let graphic = new mars3d.graphic.EllipsoidEntity({
  226. position: new mars3d.LatLngPoint(116.3, 30.9, 1000),
  227. style: {
  228. radii: new Cesium.Cartesian3(1500.0, 1500.0, 1500.0),
  229. material: Cesium.Color.RED.withAlpha(0.5),
  230. outline: true,
  231. outlineColor: Cesium.Color.WHITE.withAlpha(0.3),
  232. },
  233. });
  234. graphicLayer.addGraphic(graphic);
  235. }
  236. function addGraphic_e09(graphicLayer) {
  237. let graphic = new mars3d.graphic.ModelEntity({
  238. name: "消防员",
  239. position: [116.4, 30.9, 1000],
  240. style: {
  241. url: "//data.mars3d.cn/gltf/mars/firedrill/xiaofangyuan-run.gltf",
  242. scale: 16,
  243. minimumPixelSize: 100,
  244. },
  245. });
  246. graphicLayer.addGraphic(graphic);
  247. }
  248. function addGraphic_e10(graphicLayer) {
  249. let graphic = new mars3d.graphic.PolylineEntity({
  250. positions: [
  251. [116.5, 30.9, 1000],
  252. [116.52, 30.91, 1000],
  253. [116.53, 30.89, 1000],
  254. ],
  255. style: {
  256. width: 5,
  257. color: "#3388ff",
  258. },
  259. });
  260. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  261. }
  262. function addGraphic_e11(graphicLayer) {
  263. let graphic = new mars3d.graphic.PolylineVolumeEntity({
  264. positions: [
  265. [116.1, 30.8, 1000],
  266. [116.12, 30.81, 1000],
  267. [116.13, 30.79, 1000],
  268. ],
  269. style: {
  270. shape: "pipeline",
  271. radius: 80,
  272. color: "#3388ff",
  273. opacity: 0.9,
  274. },
  275. });
  276. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  277. }
  278. function addGraphic_e12(graphicLayer) {
  279. let graphic = new mars3d.graphic.CorridorEntity({
  280. positions: [
  281. [116.2, 30.8, 1000],
  282. [116.22, 30.81, 1000],
  283. [116.23, 30.79, 1000],
  284. [116.247328, 30.806077, 610.41],
  285. ],
  286. style: {
  287. width: 500,
  288. color: "#3388ff",
  289. },
  290. });
  291. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  292. }
  293. function addGraphic_e13(graphicLayer) {
  294. let graphic = new mars3d.graphic.WallEntity({
  295. positions: [
  296. [116.3, 30.8, 1000],
  297. [116.31, 30.81, 1000],
  298. [116.334639, 30.800735, 721.39],
  299. [116.32, 30.79, 1000],
  300. ],
  301. style: {
  302. closure: true,
  303. diffHeight: 500,
  304. //动画线材质
  305. material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.LineFlow, {
  306. image: "img/textures/fence.png",
  307. color: "#00ff00",
  308. speed: 10,
  309. axisY: true,
  310. }),
  311. },
  312. });
  313. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  314. }
  315. function addGraphic_e14(graphicLayer) {
  316. let graphic = new mars3d.graphic.RectangleEntity({
  317. positions: [
  318. [116.383144, 30.819978, 444.42],
  319. [116.42216, 30.793431, 1048.07],
  320. ],
  321. style: {
  322. color: "#3388ff",
  323. opacity: 0.5,
  324. outline: true,
  325. outlineWidth: 3,
  326. outlineColor: "#ffffff",
  327. },
  328. });
  329. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  330. }
  331. function addGraphic_e15(graphicLayer) {
  332. let graphic = new mars3d.graphic.PolygonEntity({
  333. positions: [
  334. [116.510278, 30.834372, 567.29],
  335. [116.530085, 30.809331, 448.31],
  336. [116.507367, 30.788551, 98.21],
  337. [116.472468, 30.823091, 677.39],
  338. ],
  339. style: {
  340. material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.Water, {
  341. normalMap: "img/textures/waterNormals.jpg", // 水正常扰动的法线图
  342. frequency: 8000.0, // 控制波数的数字。
  343. animationSpeed: 0.02, // 控制水的动画速度的数字。
  344. amplitude: 5.0, // 控制水波振幅的数字。
  345. specularIntensity: 0.8, // 控制镜面反射强度的数字。
  346. baseWaterColor: "#006ab4", // rgba颜色对象基础颜色的水。#00ffff,#00baff,#006ab4
  347. blendColor: "#006ab4", // 从水中混合到非水域时使用的rgba颜色对象。
  348. }),
  349. },
  350. });
  351. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  352. }
  353. </script>
  354. </body>
  355. </html>