g15_dth_fd.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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>矢量单体化(GeoJson叠加) </title>
  21. <!--第三方lib-->
  22. <script
  23. type="text/javascript"
  24. src="../lib/include-lib.js"
  25. libpath="../lib/"
  26. include="jquery,font-awesome,bootstrap,bootstrap-checkbox,layer,haoutil,turf,mars3d"
  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. <div class="checkbox checkbox-primary checkbox-inline">
  37. <input id="chkShowColor" class="styled" type="checkbox" checked />
  38. <label for="chkShowColor"> 是否显示各栋颜色 </label>
  39. </div>
  40. </div>
  41. <script src="./js/common.js"></script>
  42. <script type="text/javascript">
  43. "use script"; //开发环境建议开启严格模式
  44. var map;
  45. function initMap(options) {
  46. //合并属性参数,可覆盖config.json中的对应配置
  47. var mapOptions = mars3d.Util.merge(options, {
  48. scene: {
  49. center: { lat: 43.821193, lng: 125.143124, alt: 990, heading: 342, pitch: -50 },
  50. },
  51. });
  52. //创建三维地球场景
  53. map = new mars3d.Map("mars3dContainer", mapOptions);
  54. //三维模型
  55. var tilesetLayer = new mars3d.layer.TilesetLayer({
  56. type: "3dtiles",
  57. name: "校园",
  58. url: "//data.mars3d.cn/3dtiles/qx-xuexiao/tileset.json",
  59. position: { alt: 15.8 },
  60. maximumScreenSpaceError: 1,
  61. maximumMemoryUsage: 1024,
  62. });
  63. map.addLayer(tilesetLayer);
  64. //单体化图层
  65. var geoJsonLayerDTH = new mars3d.layer.GeoJsonLayer({
  66. name: "学校-单体化",
  67. url: "//data.mars3d.cn/file/geojson/dth-xuexiao-fd.json",
  68. symbol: {
  69. type: "polygonP",
  70. styleOptions: {
  71. //单体化默认显示样式
  72. color: "#00ffff",
  73. opacity: 0.2,
  74. clampToGround: true,
  75. classification: true,
  76. buffer: 1,
  77. //单体化鼠标移入或单击后高亮的样式
  78. highlight: {
  79. type: mars3d.EventType.click,
  80. color: "#ffff00",
  81. opacity: 0.6,
  82. },
  83. label: {
  84. text: "{name}",
  85. height: 240, //单体化面没有高度,所以中心点文字需要指定一个高度值。
  86. opacity: 1,
  87. font_size: 30,
  88. color: "#ffffff",
  89. font_family: "楷体",
  90. outline: true,
  91. outlineColor: "#000000",
  92. outlineWidth: 3,
  93. background: false,
  94. backgroundColor: "#000000",
  95. backgroundOpacity: 0.1,
  96. scaleByDistance: true,
  97. scaleByDistance_far: 1000,
  98. scaleByDistance_farValue: 0.3,
  99. scaleByDistance_near: 10,
  100. scaleByDistance_nearValue: 1,
  101. },
  102. },
  103. },
  104. popup: [
  105. { field: "name", name: "学校场所" },
  106. { field: "sfkf", name: "是否开放" },
  107. { field: "remark", name: "备注信息" },
  108. ],
  109. });
  110. map.addLayer(geoJsonLayerDTH);
  111. $("#chkShowColor").change(function () {
  112. let val = $(this).is(":checked");
  113. geoJsonLayerDTH.closePopup();
  114. if (val) {
  115. geoJsonLayerDTH.eachGraphic((graphic, index) => {
  116. graphic.setStyle({
  117. opacity: 0.2,
  118. });
  119. });
  120. } else {
  121. geoJsonLayerDTH.eachGraphic((graphic) => {
  122. graphic.setStyle({
  123. opacity: 0.01,
  124. });
  125. });
  126. }
  127. });
  128. }
  129. </script>
  130. </body>
  131. </html>