echartsLinesEffect.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_linesEffect"></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, echartsOption,
  17. url = host + "/iserver/services/map-china400/rest/maps/ChinaDark";
  18. var map = new ol.Map({
  19. target: 'map',
  20. controls: ol.control.defaults({attributionOptions: {collapsed: false}})
  21. .extend([new ol.supermap.control.Logo()]),
  22. view: new ol.View({
  23. center: [116.402, 39.905],
  24. zoom: 10,
  25. projection: 'EPSG:4326',
  26. multiWorld: true
  27. }),
  28. layers: [new ol.layer.Tile({
  29. source: new ol.source.OSM({}),
  30. source: new ol.source.TileSuperMapRest({
  31. url: url,
  32. prjCoordSys: {"epsgCode": 4326}
  33. }),
  34. projection: 'EPSG:4326'
  35. })]
  36. });
  37. var echartslayer = new ol3Echarts(null, {
  38. hideOnMoving: true,
  39. hideOnZooming: true
  40. });
  41. echartslayer.appendTo(map);
  42. $.get('../data/lines-bus.json', function (data) {
  43. var hStep = 300 / (data.length - 1);
  44. var busLines = [].concat.apply([], data.map(function (busLine, idx) {
  45. var prevPt;
  46. var points = [];
  47. for (var i = 0; i < busLine.length; i += 2) {
  48. var pt = [busLine[i], busLine[i + 1]];
  49. if (i > 0) {
  50. pt = [
  51. prevPt[0] + pt[0],
  52. prevPt[1] + pt[1]
  53. ];
  54. }
  55. prevPt = pt;
  56. points.push([pt[0] / 1e4, pt[1] / 1e4]);
  57. }
  58. return {
  59. coords: points,
  60. lineStyle: {
  61. normal: {
  62. color: echarts.color.modifyHSL('#5A94DF', Math.round(hStep * idx))
  63. }
  64. }
  65. };
  66. }));
  67. echartsOption = {
  68. series: [
  69. {
  70. type: 'lines',
  71. polyline: true,
  72. data: busLines,
  73. silent: true,
  74. lineStyle: {
  75. normal: {
  76. opacity: 0.2,
  77. width: 1
  78. }
  79. },
  80. progressiveThreshold: 500,
  81. progressive: 200,
  82. zlevel: 2
  83. },
  84. {
  85. type: 'lines',
  86. polyline: true,
  87. data: busLines,
  88. lineStyle: {
  89. normal: {
  90. width: 0
  91. }
  92. },
  93. effect: {
  94. constantSpeed: 20,
  95. show: true,
  96. trailLength: 0.1,
  97. symbolSize: 1.5
  98. },
  99. zlevel: 1
  100. }]
  101. };
  102. echartslayer.setChartOptions(echartsOption);
  103. });
  104. </script>
  105. </body>
  106. </html>