mapvQianxi.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html lang="en-US">
  6. <head>
  7. <meta charset="UTF-8">
  8. <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  9. <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  10. <script type="text/javascript" include="mapv" src="../../dist/ol/include-ol.js"></script>
  11. <title data-i18n="resources.title_mapvQianxi"></title>
  12. <style>
  13. .ol-popup {
  14. position: absolute;
  15. background-color: white;
  16. -webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
  17. filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
  18. padding: 15px;
  19. border-radius: 10px;
  20. border: 1px solid #cccccc;
  21. bottom: 12px;
  22. left: -50px;
  23. min-width: 280px;
  24. font-size: 8pt;
  25. }
  26. .ol-popup:after, .ol-popup:before {
  27. top: 100%;
  28. border: solid transparent;
  29. content: " ";
  30. height: 0;
  31. width: 0;
  32. position: absolute;
  33. pointer-events: none;
  34. }
  35. .ol-popup:after {
  36. border-top-color: white;
  37. border-width: 10px;
  38. left: 48px;
  39. margin-left: -10px;
  40. }
  41. .ol-popup:before {
  42. border-top-color: #cccccc;
  43. border-width: 11px;
  44. left: 48px;
  45. margin-left: -11px;
  46. }
  47. .ol-popup-closer {
  48. text-decoration: none;
  49. position: absolute;
  50. top: 2px;
  51. right: 8px;
  52. }
  53. .ol-popup-closer:after {
  54. content: "✖";
  55. }
  56. </style>
  57. </head>
  58. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
  59. <div id="map" style="width: 100%;height:100%"></div>
  60. <div id="popup" class="ol-popup">
  61. <a href="#" id="popup-closer" class="ol-popup-closer"></a>
  62. <div id="popup-content" data-i18n="resources.text_iClient"></div>
  63. </div>
  64. <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
  65. <script type="text/javascript">
  66. var container = document.getElementById('popup');
  67. var closer = document.getElementById('popup-closer');
  68. var overlay = new ol.Overlay(({
  69. element: container,
  70. autoPan: true,
  71. autoPanAnimation: {
  72. duration: 250
  73. }
  74. }));
  75. closer.onclick = function () {
  76. overlay.setPosition(undefined);
  77. closer.blur();
  78. return false;
  79. };
  80. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  81. var url = host + "/iserver/services/map-china400/rest/maps/ChinaDark";
  82. var map = new ol.Map({
  83. target: 'map',
  84. controls: ol.control.defaults({attributionOptions: {collapsed: false}})
  85. .extend([new ol.supermap.control.Logo()]),
  86. view: new ol.View({
  87. center: [113.2, 37.82],
  88. zoom: 5,
  89. projection: 'EPSG:4326'
  90. }),
  91. layers: [new ol.layer.Tile({
  92. source: new ol.source.TileSuperMapRest({
  93. url: url,
  94. prjCoordSys: {"epsgCode": 4326},
  95. attributions: "Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a>"
  96. }),
  97. projection: 'EPSG:4326'
  98. })]
  99. });
  100. overlay.setPosition(map.getView().getCenter());
  101. $.get('../data/china.json', function (geojson) {
  102. var geojsonOptions = {
  103. gradient: {
  104. 0: 'rgba(55, 50, 250, 0.4)',
  105. 1: 'rgba(55, 50, 250, 1)'
  106. },
  107. max: 354551,
  108. draw: 'intensity'
  109. };
  110. var geojsonDataSet = mapv.geojson.getDataSet(geojson);
  111. var to = '北京';
  112. var qianxi = new mapv.DataSet([
  113. {
  114. from: '河北',
  115. count: 354551,
  116. to: to,
  117. },
  118. {
  119. from: '天津',
  120. count: 97323,
  121. to: to,
  122. },
  123. {
  124. from: '山东',
  125. count: 28664,
  126. to: to,
  127. },
  128. {
  129. from: '山西',
  130. count: 16650,
  131. to: to,
  132. },
  133. {
  134. from: '辽宁',
  135. count: 14379,
  136. to: to,
  137. },
  138. {
  139. from: '河南',
  140. count: 10980,
  141. to: to,
  142. },
  143. {
  144. from: '内蒙古自治区',
  145. count: 9603,
  146. to: to,
  147. },
  148. {
  149. from: '江苏',
  150. count: 4536,
  151. to: to,
  152. },
  153. {
  154. from: '上海',
  155. count: 3556,
  156. to: to,
  157. },
  158. {
  159. from: '广东',
  160. count: 2600,
  161. to: to,
  162. },
  163. ]);
  164. var qianxiData = qianxi.get();
  165. var lineData = [];
  166. var pointData = [];
  167. var textData = [];
  168. var timeData = [];
  169. var citys = {};
  170. for (var i = 0; i < qianxiData.length; i++) {
  171. var fromCenter = mapv.utilCityCenter.getCenterByCityName(qianxiData[i].from);
  172. var toCenter = mapv.utilCityCenter.getCenterByCityName(qianxiData[i].to);
  173. if (!fromCenter || !toCenter) {
  174. continue;
  175. }
  176. citys[qianxiData[i].from] = qianxiData[i].count;
  177. citys[qianxiData[i].to] = 100;
  178. pointData.push(
  179. {
  180. geometry: {
  181. type: 'Point',
  182. coordinates: [fromCenter.lng, fromCenter.lat]
  183. }
  184. }
  185. );
  186. pointData.push(
  187. {
  188. geometry: {
  189. type: 'Point',
  190. coordinates: [toCenter.lng, toCenter.lat]
  191. }
  192. }
  193. );
  194. textData.push(
  195. {
  196. geometry: {
  197. type: 'Point',
  198. coordinates: [fromCenter.lng, fromCenter.lat]
  199. },
  200. text: qianxiData[i].from
  201. }
  202. );
  203. textData.push(
  204. {
  205. geometry: {
  206. type: 'Point',
  207. coordinates: [toCenter.lng, toCenter.lat]
  208. },
  209. text: qianxiData[i].to
  210. }
  211. );
  212. var curve = mapv.utilCurve.getPoints([fromCenter, toCenter]);
  213. for (j = 0; j < curve.length; j++) {
  214. timeData.push({
  215. geometry: {
  216. type: 'Point',
  217. coordinates: curve[j]
  218. },
  219. count: 1,
  220. time: j
  221. });
  222. }
  223. lineData.push({
  224. geometry: {
  225. type: 'LineString',
  226. coordinates: curve
  227. //coordinates: [[fromCenter.lng, fromCenter.lat], [toCenter.lng, toCenter.lat]]
  228. },
  229. count: 30 * Math.random()
  230. });
  231. }
  232. var data = geojsonDataSet.get({
  233. filter: function (item) {
  234. if (!citys[item.name]) {
  235. return false;
  236. }
  237. item.count = citys[item.name];
  238. return true;
  239. }
  240. });
  241. geojsonDataSet = new mapv.DataSet(data);
  242. map.addLayer(new ol.layer.Image({
  243. source: new ol.source.Mapv({map: map, dataSet: geojsonDataSet, mapvOptions: geojsonOptions})
  244. }));
  245. var textDataSet = new mapv.DataSet(textData);
  246. var textOptions = {
  247. draw: 'text',
  248. font: '14px Arial',
  249. fillStyle: 'white',
  250. shadowColor: 'yellow',
  251. shadowBlue: 10,
  252. zIndex: 11,
  253. shadowBlur: 10
  254. };
  255. map.addLayer(new ol.layer.Image({
  256. source: new ol.source.Mapv({map: map, dataSet: textDataSet, mapvOptions: textOptions})
  257. }));
  258. var lineDataSet = new mapv.DataSet(lineData);
  259. var lineOptions = {
  260. strokeStyle: 'rgba(255, 250, 50, 0.8)',
  261. shadowColor: 'rgba(255, 250, 50, 1)',
  262. shadowBlur: 20,
  263. lineWidth: 2,
  264. zIndex: 100,
  265. draw: 'simple'
  266. };
  267. map.addLayer(new ol.layer.Image({
  268. source: new ol.source.Mapv({map: map, dataSet: lineDataSet, mapvOptions: lineOptions})
  269. }));
  270. var pointOptions = {
  271. fillStyle: 'rgba(254,175,3,0.7)',
  272. shadowColor: 'rgba(55, 50, 250, 0.5)',
  273. shadowBlur: 10,
  274. size: 5,
  275. zIndex: 10,
  276. draw: 'simple'
  277. };
  278. var pointDataSet = new mapv.DataSet(pointData);
  279. map.addLayer(new ol.layer.Image({
  280. source: new ol.source.Mapv({map: map, dataSet: pointDataSet, mapvOptions: pointOptions})
  281. }));
  282. var timeDataSet = new mapv.DataSet(timeData);
  283. var timeOptions = {
  284. fillStyle: 'rgba(255, 250, 250, 0.5)',
  285. zIndex: 200,
  286. size: 2.5,
  287. animation: {
  288. type: 'time',
  289. stepsRange: {
  290. start: 0,
  291. end: 50
  292. },
  293. trails: 10,
  294. duration: 2,
  295. },
  296. draw: 'simple'
  297. };
  298. map.addLayer(new ol.layer.Image({
  299. source: new ol.source.Mapv({map: map, dataSet: timeDataSet, mapvOptions: timeOptions})
  300. }));
  301. });
  302. </script>
  303. </body>
  304. </html>