mapVLayerQianxi.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_mapvQianxi"></title>
  9. <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
  10. </head>
  11. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  12. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  13. <script type="text/javascript" include="mapv" src="../../dist/leaflet/include-leaflet.js"></script>
  14. <script type="text/javascript">
  15. var map = L.map('map', {
  16. center: [36.64, 108.15],
  17. zoom: 5,
  18. });
  19. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  20. var url = host + "/iserver/services/map-china400/rest/maps/ChinaDark";
  21. L.supermap.tiledMapLayer(url).addTo(map);
  22. $.get('../data/china.json', function (geojson) {
  23. var geojsonOptions = {
  24. gradient: {
  25. 0: 'rgba(55, 50, 250, 0.4)',
  26. 1: 'rgba(55, 50, 250, 1)'
  27. },
  28. max: 354551,
  29. draw: 'intensity'
  30. };
  31. var geojsonDataSet = mapv.geojson.getDataSet(geojson);
  32. var to = '北京';
  33. var qianxi = new mapv.DataSet([
  34. {
  35. from: '河北',
  36. count: 354551,
  37. to: to,
  38. },
  39. {
  40. from: '天津',
  41. count: 97323,
  42. to: to,
  43. },
  44. {
  45. from: '山东',
  46. count: 28664,
  47. to: to,
  48. },
  49. {
  50. from: '山西',
  51. count: 16650,
  52. to: to,
  53. },
  54. {
  55. from: '辽宁',
  56. count: 14379,
  57. to: to,
  58. },
  59. {
  60. from: '河南',
  61. count: 10980,
  62. to: to,
  63. },
  64. {
  65. from: '内蒙古自治区',
  66. count: 9603,
  67. to: to,
  68. },
  69. {
  70. from: '江苏',
  71. count: 4536,
  72. to: to,
  73. },
  74. {
  75. from: '上海',
  76. count: 3556,
  77. to: to,
  78. },
  79. {
  80. from: '广东',
  81. count: 2600,
  82. to: to,
  83. },
  84. ]);
  85. var qianxiData = qianxi.get();
  86. var lineData = [];
  87. var pointData = [];
  88. var textData = [];
  89. var timeData = [];
  90. var citys = {}
  91. for (var i = 0; i < qianxiData.length; i++) {
  92. var fromCenter = mapv.utilCityCenter.getCenterByCityName(qianxiData[i].from);
  93. var toCenter = mapv.utilCityCenter.getCenterByCityName(qianxiData[i].to);
  94. if (!fromCenter || !toCenter) {
  95. continue;
  96. }
  97. citys[qianxiData[i].from] = qianxiData[i].count;
  98. citys[qianxiData[i].to] = 100;
  99. pointData.push(
  100. {
  101. geometry: {
  102. type: 'Point',
  103. coordinates: [fromCenter.lng, fromCenter.lat]
  104. }
  105. }
  106. );
  107. pointData.push(
  108. {
  109. geometry: {
  110. type: 'Point',
  111. coordinates: [toCenter.lng, toCenter.lat]
  112. }
  113. }
  114. );
  115. textData.push(
  116. {
  117. geometry: {
  118. type: 'Point',
  119. coordinates: [fromCenter.lng, fromCenter.lat]
  120. },
  121. text: qianxiData[i].from
  122. }
  123. );
  124. textData.push(
  125. {
  126. geometry: {
  127. type: 'Point',
  128. coordinates: [toCenter.lng, toCenter.lat]
  129. },
  130. text: qianxiData[i].to
  131. }
  132. );
  133. var curve = mapv.utilCurve.getPoints([fromCenter, toCenter]);
  134. for (j = 0; j < curve.length; j++) {
  135. timeData.push({
  136. geometry: {
  137. type: 'Point',
  138. coordinates: curve[j]
  139. },
  140. count: 1,
  141. time: j
  142. });
  143. }
  144. lineData.push({
  145. geometry: {
  146. type: 'LineString',
  147. coordinates: curve
  148. //coordinates: [[fromCenter.lng, fromCenter.lat], [toCenter.lng, toCenter.lat]]
  149. },
  150. count: 30 * Math.random()
  151. });
  152. }
  153. var data = geojsonDataSet.get({
  154. filter: function (item) {
  155. if (!citys[item.name]) {
  156. return false;
  157. }
  158. item.count = citys[item.name];
  159. return true;
  160. }
  161. });
  162. geojsonDataSet = new mapv.DataSet(data);
  163. L.supermap.mapVLayer(geojsonDataSet, geojsonOptions).addTo(map);
  164. var textDataSet = new mapv.DataSet(textData);
  165. var textOptions = {
  166. draw: 'text',
  167. font: '14px Arial',
  168. fillStyle: 'white',
  169. shadowColor: 'yellow',
  170. shadowBlue: 10,
  171. zIndex: 11,
  172. shadowBlur: 10
  173. };
  174. L.supermap.mapVLayer(textDataSet, textOptions).addTo(map);
  175. var lineDataSet = new mapv.DataSet(lineData);
  176. var lineOptions = {
  177. strokeStyle: 'rgba(255, 250, 50, 0.8)',
  178. shadowColor: 'rgba(255, 250, 50, 1)',
  179. shadowBlur: 20,
  180. lineWidth: 2,
  181. zIndex: 100,
  182. draw: 'simple'
  183. };
  184. L.supermap.mapVLayer(lineDataSet, lineOptions).addTo(map);
  185. var pointOptions = {
  186. fillStyle: 'rgba(254,175,3,0.7)',
  187. shadowColor: 'rgba(55, 50, 250, 0.5)',
  188. shadowBlur: 10,
  189. size: 5,
  190. zIndex: 10,
  191. draw: 'simple'
  192. };
  193. var pointDataSet = new mapv.DataSet(pointData);
  194. L.supermap.mapVLayer(pointDataSet, pointOptions).addTo(map);
  195. var timeDataSet = new mapv.DataSet(timeData);
  196. var timeOptions = {
  197. fillStyle: 'rgba(255, 250, 250, 0.5)',
  198. zIndex: 200,
  199. size: 2.5,
  200. animation: {
  201. type: 'time',
  202. stepsRange: {
  203. start: 0,
  204. end: 50
  205. },
  206. trails: 10,
  207. duration: 2,
  208. },
  209. draw: 'simple'
  210. };
  211. L.supermap.mapVLayer(timeDataSet, timeOptions).addTo(map);
  212. });
  213. </script>
  214. </body>
  215. </html>