echartsLinesAirline.html 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_linesAirline"></title>
  9. <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
  10. <script type="text/javascript" include="echarts,ol3-echarts" src="../../dist/ol/include-ol.js"></script>
  11. </head>
  12. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  13. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, option, url = host + "/iserver/services/map-china400/rest/maps/ChinaDark";
  17. var map = new ol.Map({
  18. target: 'map',
  19. controls: ol.control.defaults({attributionOptions: {collapsed: false}})
  20. .extend([new ol.supermap.control.Logo()]),
  21. view: new ol.View({
  22. center: [0, 0],
  23. maxZoom: 18,
  24. zoom: 3,
  25. projection: 'EPSG:4326',
  26. multiWorld: true
  27. }),
  28. layers: [new ol.layer.Tile({
  29. source: new ol.source.TileSuperMapRest({
  30. url: url,
  31. prjCoordSys: {"epsgCode": 4326}
  32. }),
  33. projection: 'EPSG:4326'
  34. })]
  35. });
  36. var echartslayer = new ol3Echarts(null, {
  37. hideOnMoving: true,
  38. hideOnZooming: true
  39. });
  40. echartslayer.appendTo(map);
  41. $.get('../data/flights.json', function (data) {
  42. function getAirportCoord(idx) {
  43. return [data.airports[idx][3], data.airports[idx][4]];
  44. }
  45. var routes = data.routes.map(function (airline) {
  46. return [
  47. getAirportCoord(airline[1]),
  48. getAirportCoord(airline[2])
  49. ];
  50. });
  51. option = {
  52. title: {
  53. text: 'World Flights',
  54. left: 'center',
  55. textStyle: {
  56. color: '#fff'
  57. }
  58. },
  59. tooltip: {
  60. formatter: function (param) {
  61. var route = data.routes[param.dataIndex];
  62. return data.airports[route[1]][1] + ' > ' + data.airports[route[2]][1];
  63. }
  64. },
  65. series: [{
  66. type: 'lines',
  67. data: routes,
  68. large: true,
  69. largeThreshold: 100,
  70. lineStyle: {
  71. normal: {
  72. opacity: 0.05,
  73. width: 0.5,
  74. curveness: 0.3
  75. }
  76. },
  77. // 设置混合模式为叠加
  78. blendMode: 'lighter'
  79. }]
  80. };
  81. echartslayer.setChartOptions(option);
  82. });
  83. </script>
  84. </body>
  85. </html>