k15_floodByGraphic.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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,jquery.range,font-awesome,bootstrap,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. <table id="paramView" class="mars-table">
  37. <tr>
  38. <td class="nametd">分析区域</td>
  39. <td>
  40. <button type="button" id="btnDrawExtent" class="btn btn-default">绘制矩形</button>
  41. <button type="button" id="btnDraw" class="btn btn-default">绘制多边形</button>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td class="nametd">最低海拔(米)</td>
  46. <td>
  47. <input id="minHeight" value="" type="number" class="form-control" />
  48. </td>
  49. </tr>
  50. <tr>
  51. <td class="nametd">最高海拔(米)</td>
  52. <td>
  53. <input id="maxHeight" value="" type="number" class="form-control" />
  54. </td>
  55. </tr>
  56. <tr>
  57. <td class="nametd">淹没速度(米/秒)</td>
  58. <td>
  59. <input id="speed" value="10" type="number" class="form-control" />
  60. </td>
  61. </tr>
  62. <tr>
  63. <td colspan="2">
  64. <button type="button" id="begin" class="btn btn-primary">开始分析</button>
  65. </td>
  66. </tr>
  67. </table>
  68. <div id="resultView" style="display: none; text-align: left">
  69. <div class="rowview clearfix">
  70. <span>高度选择:</span>
  71. <input id="range_currHeight" title="时间" type="range" min="0" max="1000" step="0.1" value="0" />
  72. </div>
  73. <div class="rowview clearfix"><span>当前高度:</span><span id="lbl_nowHeight"></span></div>
  74. <input id="btn_start" type="button" class="btn btn-primary" value="自动播放" />
  75. <button type="button" id="clear" class="btn btn-danger">返回</button>
  76. </div>
  77. </div>
  78. <script src="./js/common.js"></script>
  79. <script type="text/javascript">
  80. "use script"; //开发环境建议开启严格模式
  81. var map;
  82. var floodByGraphic;
  83. function initMap(options) {
  84. //合并属性参数,可覆盖config.json中的对应配置
  85. var mapOptions = mars3d.Util.merge(options, {});
  86. //创建三维地球场景
  87. map = new mars3d.Map("mars3dContainer", mapOptions);
  88. var speed = Number($("#speed").val());
  89. // 基于polygon矢量面抬高模拟,只支持单个区域
  90. floodByGraphic = new mars3d.thing.FloodByGraphic({
  91. speed: speed,
  92. style: {
  93. color: "#007be6",
  94. opacity: 0.5,
  95. outline: false,
  96. },
  97. });
  98. map.addThing(floodByGraphic);
  99. floodByGraphic.on(mars3d.EventType.start, function (e) {
  100. console.log("开始分析", e);
  101. });
  102. floodByGraphic.on(mars3d.EventType.change, function (e) {
  103. console.log("分析中,高度变化了", e);
  104. onChangeHeight(e.height);
  105. });
  106. floodByGraphic.on(mars3d.EventType.end, function (e) {
  107. console.log("结束分析", e);
  108. });
  109. let drawPotions;
  110. $("#btnDraw").click(function () {
  111. drawPotions = null;
  112. map.graphicLayer.clear();
  113. map.graphicLayer.startDraw({
  114. type: "polygon",
  115. style: {
  116. color: "#007be6",
  117. opacity: 0.5,
  118. outline: false,
  119. },
  120. success: function (graphic) {
  121. var positions = graphic.positionsShow;
  122. drawPotions = positions;
  123. //求最大、最小高度值
  124. haoutil.loading.show();
  125. var result = mars3d.PolyUtil.getHeightRange(positions, map.scene);
  126. $("#minHeight").val(Math.ceil(result.minHeight));
  127. $("#maxHeight").val(Math.floor(result.maxHeight));
  128. haoutil.loading.hide();
  129. },
  130. });
  131. });
  132. $("#btnDrawExtent").click(function () {
  133. drawPotions = null;
  134. map.graphicLayer.clear();
  135. map.graphicLayer.startDraw({
  136. type: "rectangle",
  137. style: {
  138. color: "#007be6",
  139. opacity: 0.8,
  140. outline: false,
  141. },
  142. success: function (graphic) {
  143. //绘制成功后回调
  144. var positions = graphic.getOutlinePositions(false);
  145. //区域
  146. drawPotions = positions;
  147. //求最大、最小高度值
  148. haoutil.loading.show();
  149. var result = mars3d.PolyUtil.getHeightRange(positions, map.scene);
  150. $("#minHeight").val(Math.ceil(result.minHeight));
  151. $("#maxHeight").val(Math.floor(result.maxHeight));
  152. haoutil.loading.hide();
  153. },
  154. });
  155. });
  156. $("#begin").click(function () {
  157. if (drawPotions == null) {
  158. haoutil.msg("请首先绘制分析区域!");
  159. return;
  160. }
  161. map.graphicLayer.clear();
  162. floodByGraphic.positions = drawPotions;
  163. var minValue = Number($("#minHeight").val());
  164. var maxValue = Number($("#maxHeight").val());
  165. var speed = Number($("#speed").val());
  166. floodByGraphic.setOptions({
  167. minHeight: minValue,
  168. maxHeight: maxValue,
  169. speed: speed,
  170. });
  171. $("#range_currHeight").attr("min", minValue);
  172. $("#range_currHeight").attr("max", maxValue);
  173. onChangeHeight(minValue);
  174. $("#paramView").hide();
  175. $("#resultView").show();
  176. $("#btn_start").click(); //自动启动
  177. });
  178. //滑动条
  179. $("#range_currHeight").range({
  180. onChange: function (value, bfb) {
  181. floodByGraphic.height = value;
  182. $("#lbl_nowHeight").html(value.toFixed(1));
  183. $("#btn_start").val("自动播放");
  184. },
  185. });
  186. $("#btn_start").click(function () {
  187. if (floodByGraphic.isStart) {
  188. floodByGraphic.stop();
  189. $("#btn_start").val("自动播放");
  190. } else {
  191. floodByGraphic.start();
  192. $("#btn_start").val("暂停");
  193. }
  194. });
  195. $("#clear").click(function () {
  196. $("#resultView").hide();
  197. $("#paramView").show();
  198. $("#btn_start").val("自动播放");
  199. drawPotions = null;
  200. floodByGraphic.clear();
  201. map.graphicLayer.clear();
  202. });
  203. }
  204. function onChangeHeight(height) {
  205. $("#range_currHeight").val(height).change();
  206. $("#lbl_nowHeight").html(height.toFixed(1));
  207. }
  208. </script>
  209. </body>
  210. </html>