summaryAttributesJobService.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html lang="en">
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_summaryAttributesJobService"></title>
  9. <style>
  10. .mb-popup {
  11. position: absolute;
  12. top: 10px;
  13. right: 10px;
  14. }
  15. .mb-echarts {
  16. position: absolute;
  17. top: 30px;
  18. left: 10px;
  19. width: 400px;
  20. height: 300px;
  21. }
  22. </style>
  23. </head>
  24. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  25. <div id="map" style="width: 100%;height:100%"></div>
  26. <div id="popup" class="mb-popup" style='width:350px'>
  27. <div class="panel panel-default">
  28. <div class='panel-heading'>
  29. <h3 class='panel-title' data-i18n="resources.title_summaryAttributesJobService"></h3>
  30. </div>
  31. <div class='panel-body'>
  32. <div class='input-group'>
  33. <span class='input-group-addon'><span data-i18n="resources.text_inputData"></span><span data-i18n="[title]resources.text_requiredField"
  34. style="color: red;"> * </span> </span>
  35. <input id='datasetName' type='text' class='form-control' value='samples_processing_newyorkZone_R' />
  36. </div>
  37. <p></p>
  38. <div class='input-group'>
  39. <span class='input-group-addon' data-i18n="resources.text_groupField"></span>
  40. <input id='groupField' type='text' class='form-control' value='borough' />
  41. </div>
  42. <p></p>
  43. <div class='input-group'>
  44. <span class='input-group-addon' data-i18n="resources.text_attributeField"></span>
  45. <input id='attributeField' type='text' class='form-control' value='LocationID' />
  46. </div>
  47. <p></p>
  48. <div class='input-group'>
  49. <span class='input-group-addon' data-i18n="resources.text_statisticModes"></span>
  50. <input id='statisticModes' type='text' class='form-control' value='sum' />
  51. </div>
  52. <p></p>
  53. <div align='right'>
  54. <input type='button' id='btn' class='btn btn-primary' data-i18n="[value]resources.btn_summary" />
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <div id="echarts" class="mb-echarts"></div>
  60. <script type="text/javascript" include="bootstrap,jquery,widgets" src="../js/include-web.js"></script>
  61. <script type="text/javascript" include="echarts" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  62. <script>
  63. var map,
  64. baseUrl = (window.isLocal ? window.server : "https://iserver.supermap.io") +
  65. "/iserver/services/map-world/rest/maps/World",
  66. mapUrl = baseUrl + "/zxyTileImage.png?z={z}&x={x}&y={y}",
  67. processingsUrl = (window.isLocal ? window.server : "https://iserver.supermap.io") +
  68. "/iserver/services/distributedanalyst/rest/v1/jobs";
  69. var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  70. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  71. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
  72. map = new mapboxgl.Map({
  73. container: 'map',
  74. style: {
  75. "version": 8,
  76. "sources": {
  77. "raster-tiles": {
  78. "attribution": attribution,
  79. "type": "raster",
  80. "tiles": [mapUrl],
  81. "tileSize": 256
  82. }
  83. },
  84. "layers": [{
  85. "id": "simple-tiles",
  86. "type": "raster",
  87. "source": "raster-tiles",
  88. }]
  89. },
  90. center: [-73.95, 40.75],
  91. zoom: 11
  92. });
  93. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  94. map.addControl(new mapboxgl.supermap.LogoControl(), 'bottom-right');
  95. bindClick();
  96. SuperMap.SecurityManager.registerToken(processingsUrl, window.exampleToken);
  97. var processingService = new mapboxgl.supermap.ProcessingService(processingsUrl, {
  98. withCredentials: window.isLocal
  99. });
  100. function bindClick() {
  101. $('#btn').on('click', function () {
  102. if ($('#msg_container')[0]) {
  103. $('#msg_container').remove();
  104. }
  105. widgets.loader.showLoader();
  106. $("#echarts").html("");
  107. $("#echarts").hide();
  108. summaryAttributesJobs();
  109. });
  110. }
  111. function summaryAttributesJobs() {
  112. var summaryAttributesJobsParameter = new SuperMap.SummaryAttributesJobsParameter({
  113. datasetName: $('#datasetName').val(),
  114. groupField: $('#groupField').val(),
  115. attributeField: $('#attributeField').val(),
  116. statisticModes: $('#statisticModes').val()
  117. });
  118. processingService.addSummaryAttributesJob(summaryAttributesJobsParameter, function (serviceResult) {
  119. if (serviceResult.error) {
  120. widgets.loader.removeLoader();
  121. var errorMsg = serviceResult.error.errorMsg || "code: " + serviceResult.error;
  122. widgets.alert.showAlert(resources.msg_createFailed + "<br>" + errorMsg, false);
  123. return;
  124. }
  125. serviceResult.result.setting.serviceInfo.targetServiceInfos.map(function (info) {
  126. if (info.serviceType === 'RESTDATA') {
  127. var dataUrl = info.serviceAddress + '/data';
  128. var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
  129. queryParameter: {
  130. name: "analystResult@UntitledDatasource",
  131. attributeFilter: "SMID > 0"
  132. },
  133. datasetNames: ["UntitledDatasource:analystResult"]
  134. });
  135. new mapboxgl.supermap.FeatureService(dataUrl).getFeaturesBySQL(sqlParam,
  136. function (serviceResult) {
  137. result = serviceResult.result.features.features;
  138. var names = [];
  139. var data1 = [];
  140. var data2 = [];
  141. for (var i = 0; i < result.length; i++) {
  142. names.push(result[i].properties.BOROUGH);
  143. data1.push(parseFloat(result[i].properties.RECORDCOUNT));
  144. data2.push(parseFloat(result[i].properties.SUM_LOCATIONID));
  145. }
  146. $("#echarts").show();
  147. var ChartDom = document.createElement("div");
  148. ChartDom.id = "piechart";
  149. ChartDom.style.width = "400px";
  150. ChartDom.style.height = "300px";
  151. ChartDom.style.left = "10px";
  152. ChartDom.style.top = "110px";
  153. ChartDom.style.position = "absolute";
  154. $("#echarts").append(ChartDom);
  155. var chart = echarts.init(ChartDom);
  156. option = {
  157. backgroundColor: '#0E2A43',
  158. legend: {
  159. bottom: 20,
  160. textStyle: {
  161. color: '#fff',
  162. },
  163. data: ['RECORDCOUNT', 'SUM_LOCATIONID']
  164. },
  165. grid: {
  166. left: '3%',
  167. right: '4%',
  168. bottom: '20%',
  169. containLabel: true
  170. },
  171. tooltip: {
  172. show: "true",
  173. trigger: 'axis',
  174. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  175. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  176. }
  177. },
  178. xAxis: {
  179. type: 'value',
  180. axisTick: {
  181. show: false
  182. },
  183. axisLine: {
  184. show: false,
  185. lineStyle: {
  186. color: '#fff',
  187. }
  188. },
  189. splitLine: {
  190. show: false
  191. },
  192. },
  193. yAxis: [{
  194. type: 'category',
  195. data: names,
  196. axisTick: {
  197. show: false
  198. },
  199. axisLine: {
  200. show: true,
  201. lineStyle: {
  202. color: '#fff',
  203. }
  204. }
  205. },
  206. {
  207. type: 'category',
  208. data: names,
  209. axisLine: {
  210. show: false
  211. },
  212. axisTick: {
  213. show: false
  214. },
  215. axisLabel: {
  216. show: false
  217. },
  218. splitArea: {
  219. show: false
  220. },
  221. splitLine: {
  222. show: false
  223. }
  224. }
  225. ],
  226. series: [{
  227. name: 'RECORDCOUNT',
  228. type: 'bar',
  229. itemStyle: {
  230. normal: {
  231. show: true,
  232. color: '#5de3e1',
  233. barBorderRadius: 50,
  234. borderWidth: 0,
  235. borderColor: '#333',
  236. }
  237. },
  238. data: data1,
  239. barGap: '0%',
  240. barCategoryGap: '50%'
  241. },
  242. {
  243. name: 'SUM_LOCATIONID',
  244. type: 'bar',
  245. yAxisIndex: 1,
  246. itemStyle: {
  247. normal: {
  248. show: true,
  249. color: '#277ace',
  250. barBorderRadius: 50,
  251. borderWidth: 0,
  252. borderColor: '#333',
  253. }
  254. },
  255. data: data2,
  256. barGap: '0%',
  257. barCategoryGap: '50%'
  258. }
  259. ]
  260. };
  261. chart.setOption(option);
  262. });
  263. widgets.loader.removeLoader();
  264. }
  265. });
  266. });
  267. }
  268. </script>
  269. </body>
  270. </html>