0HL_f70_query_arcgis.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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,font-awesome,web-icons,bootstrap,bootstrap-table,bootstrap-checkbox,layer,toastr,haoutil,turf,mars3d"
  27. ></script>
  28. <link href="css/style.css" rel="stylesheet" />
  29. <style>
  30. .querybar-page {
  31. margin: 10px 0 0 0;
  32. font-size: 12px;
  33. }
  34. .querybar-ye a {
  35. text-decoration: none;
  36. padding: 4px 6px;
  37. color: #fff;
  38. border: solid 1px #ccc;
  39. margin-right: 4px;
  40. }
  41. .querybar-ye a:hover {
  42. color: #fff;
  43. border-color: #dcdcdc;
  44. }
  45. .querybar-fl {
  46. float: left;
  47. }
  48. .querybar-fr {
  49. float: right;
  50. }
  51. </style>
  52. </head>
  53. <body class="dark">
  54. <!--加载前进行操作提示,优化用户体验-->
  55. <div id="mask" class="signmask" onclick="removeMask()"></div>
  56. <div id="mars3dContainer" class="mars3d-container"></div>
  57. <div class="infoview">
  58. <table class="mars-table">
  59. <tr>
  60. <td class="nametd">名称:</td>
  61. <td>
  62. <input id="queryText" type="text" placeholder="请输入查询关键字" value="" class="form-control" />
  63. </td>
  64. </tr>
  65. <tr>
  66. <td class="nametd">范围:</td>
  67. <td>
  68. <input type="button" class="btn btn-primary" value="框选范围" id="drawRectangle" />
  69. <input type="button" class="btn btn-primary" value="圆形范围" id="drawCircle" />
  70. <input type="button" class="btn btn-primary" value="多边形范围" id="drawPolygon" />
  71. </td>
  72. </tr>
  73. <tr>
  74. <td class="nametd">范围:</td>
  75. <td>
  76. <input type="button" class="btn btn-primary" value="查询" id="query" />
  77. <input type="button" class="btn btn-primary" value="清除" id="removeAll" />
  78. </td>
  79. </tr>
  80. </table>
  81. <div id="resultView" style="max-width: 500px; display: none">
  82. <table id="table" style="table-layout: fixed; word-break: break-all"></table>
  83. <div class="querybar-page">
  84. <div class="querybar-fl">找到<strong id="lbl-allCount">0</strong>条结果</div>
  85. <div class="querybar-ye querybar-fr">
  86. <span id="lbl-pageIndex">1</span>/<span id="lbl-allPage">1</span>页 <a href="javascript:showFirstPage()">首页</a>
  87. <a href="javascript:showPretPage()">&lt;</a>
  88. <a href="javascript:showNextPage()">&gt;</a>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. <script src="./js/common.js"></script>
  94. <script type="text/javascript">
  95. "use script"; //开发环境建议开启严格模式
  96. var map;
  97. var queryMapserver;
  98. var geoJsonLayer;
  99. var drawGraphic;
  100. var $table;
  101. function initMap(options) {
  102. //合并属性参数,可覆盖config.json中的对应配置
  103. var mapOptions = mars3d.Util.merge(options, {
  104. scene: {
  105. center: { lat: 31.79536, lng: 117.255222, alt: 16294, heading: 358, pitch: -76 },
  106. },
  107. });
  108. //创建三维地球场景
  109. map = new mars3d.Map("mars3dContainer", mapOptions);
  110. queryMapserver = new mars3d.query.QueryArcServer({
  111. url: "//server.mars3d.cn/arcgis/rest/services/mars/hfghss/MapServer/2",
  112. popup: "all",
  113. pageSize: 6,
  114. });
  115. //用于显示查询结果(geojson)的图层
  116. geoJsonLayer = new mars3d.layer.GeoJsonLayer({
  117. symbol: {
  118. styleOptions: {
  119. image: "img/marker/mark3.png",
  120. scale: 1,
  121. scaleByDistance: true,
  122. scaleByDistance_far: 20000,
  123. scaleByDistance_farValue: 0.5,
  124. scaleByDistance_near: 1000,
  125. scaleByDistance_nearValue: 1,
  126. clampToGround: true,
  127. highlight: { type: "click", image: "img/marker/mark1.png" },
  128. label: {
  129. text: "{项目名称}",
  130. font_size: 25,
  131. color: "#ffffff",
  132. outline: true,
  133. outlineColor: "#000000",
  134. pixelOffsetY: -25,
  135. scaleByDistance: true,
  136. scaleByDistance_far: 80000,
  137. scaleByDistance_farValue: 0.5,
  138. scaleByDistance_near: 1000,
  139. scaleByDistance_nearValue: 1,
  140. distanceDisplayCondition: true,
  141. distanceDisplayCondition_far: 80000,
  142. distanceDisplayCondition_near: 0,
  143. },
  144. },
  145. },
  146. popup: "all",
  147. });
  148. map.addLayer(geoJsonLayer);
  149. geoJsonLayer.on(mars3d.EventType.load, geoJsonLayer_onLoadHandler);
  150. //框选查询 多边行
  151. $("#drawPolygon").click(function () {
  152. clearAll();
  153. map.graphicLayer.startDraw({
  154. type: "polygon",
  155. style: {
  156. color: "#00FF00",
  157. opacity: 0.3,
  158. outline: true,
  159. outlineColor: "#ffffff",
  160. clampToGround: true,
  161. },
  162. success: function (graphic) {
  163. drawGraphic = graphic;
  164. console.log("多边行:", drawGraphic.toGeoJSON());
  165. },
  166. });
  167. });
  168. //框选查询 矩形
  169. $("#drawRectangle").click(function () {
  170. clearAll();
  171. map.graphicLayer.startDraw({
  172. type: "rectangle",
  173. style: {
  174. color: "#00FF00",
  175. opacity: 0.3,
  176. outline: true,
  177. outlineColor: "#ffffff",
  178. clampToGround: true,
  179. },
  180. success: function (graphic) {
  181. drawGraphic = graphic;
  182. console.log("矩形:", drawGraphic.toGeoJSON({ outline: true }));
  183. },
  184. });
  185. });
  186. //框选查询 圆
  187. $("#drawCircle").click(function () {
  188. clearAll();
  189. map.graphicLayer.startDraw({
  190. type: "circle",
  191. style: {
  192. color: "#00FF00",
  193. opacity: 0.3,
  194. outline: true,
  195. outlineColor: "#ffffff",
  196. clampToGround: true,
  197. },
  198. success: function (graphic) {
  199. drawGraphic = graphic;
  200. console.log("圆:", drawGraphic.toGeoJSON({ outline: true }));
  201. },
  202. });
  203. });
  204. $("#removeAll").click(function () {
  205. clearAll();
  206. });
  207. $("#query").click(function () {
  208. queryData();
  209. });
  210. $table = $("#table");
  211. $table.bootstrapTable({
  212. singleSelect: true, //单选
  213. iconsPrefix: "fa",
  214. pagination: false,
  215. columns: [
  216. {
  217. title: "", //序号
  218. sortable: false,
  219. align: "center",
  220. width: 50,
  221. formatter: function (value, row, index) {
  222. return index + 1;
  223. },
  224. },
  225. {
  226. field: "项目名称",
  227. title: "名称",
  228. sortable: true,
  229. width: 100,
  230. },
  231. {
  232. field: "设施类型",
  233. title: "类型",
  234. sortable: true,
  235. align: "center",
  236. width: 70,
  237. },
  238. {
  239. field: "具体位置",
  240. title: "地址",
  241. sortable: true,
  242. formatter: function (value, row) {
  243. if (value) {
  244. return value;
  245. } else {
  246. return "";
  247. }
  248. },
  249. },
  250. ],
  251. onClickRow: function (item, $element, field) {
  252. var graphic = item.graphic;
  253. if (graphic == null) {
  254. toastr.warning(item.name + " 无经纬度坐标信息!");
  255. return;
  256. }
  257. graphic.openHighlight();
  258. graphic.flyTo({
  259. radius: 1000, //点数据:radius控制视距距离
  260. scale: 1.5, //线面数据:scale控制边界的放大比例
  261. complete: () => {
  262. graphic.openPopup();
  263. },
  264. });
  265. },
  266. });
  267. }
  268. function clearAll(noClearDraw) {
  269. $("#resultView").hide();
  270. drawGraphic = null;
  271. map.graphicLayer.clear();
  272. geoJsonLayer.clear();
  273. }
  274. function queryData() {
  275. $("#resultView").hide();
  276. var queryVal = $.trim($("#queryText").val());
  277. queryMapserver.query({
  278. column: "项目名称",
  279. text: queryVal,
  280. graphic: drawGraphic,
  281. success: (result) => {
  282. if (result.count == 0) {
  283. haoutil.msg("未查询到相关记录!");
  284. return;
  285. }
  286. $("#lbl-allCount").html(result.allCount);
  287. $("#lbl-allPage").html(result.allPage);
  288. $("#lbl-pageIndex").html(result.pageIndex);
  289. geoJsonLayer.load({ data: result.geojson });
  290. },
  291. error: (error, msg) => {
  292. console.log("服务访问错误", error);
  293. haoutil.alert(msg, "服务访问错误");
  294. },
  295. });
  296. }
  297. function geoJsonLayer_onLoadHandler(event) {
  298. $table.bootstrapTable("load", event.list);
  299. $("#resultView").show();
  300. }
  301. // 首页
  302. function showFirstPage() {
  303. queryMapserver.showFirstPage();
  304. }
  305. // 上一页
  306. function showPretPage() {
  307. queryMapserver.showPretPage();
  308. }
  309. // 下一页
  310. function showNextPage() {
  311. queryMapserver.showNextPage();
  312. }
  313. </script>
  314. </body>
  315. </html>