scatter-gps.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Scatter</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  7. <meta name="apple-mobile-web-app-capable" content="yes"> <!-- Fullscreen Landscape on iOS -->
  8. </head>
  9. <body>
  10. <style>
  11. html, body, #main {
  12. background: #111;
  13. width: 100%;
  14. height: 100%;
  15. margin: 0;
  16. }
  17. </style>
  18. <div id="main"></div>
  19. <div id="data-count">
  20. <span>LOADED: </span>
  21. <span id="data-count-number"></span>
  22. </div>
  23. <style>
  24. #data-count {
  25. font-size: 30px;
  26. color: #fff;
  27. position: absolute;
  28. z-index: 1000;
  29. left: 10px;
  30. bottom: 10px;
  31. }
  32. #data-count-number {
  33. font-size: 80px;
  34. }
  35. </style>
  36. <script src="../dist/echarts.js"></script>
  37. <script src="../map/js/world.js"></script>
  38. <script src="lib/jquery.min.js"></script>
  39. <script src="lib/countup.js"></script>
  40. <script>
  41. var chart = echarts.init(document.getElementById('main'));
  42. var dataCount = 0;
  43. var CHUNK_COUNT = 200;
  44. // var CHUNK_COUNT = 20;
  45. // https://blog.openstreetmap.org/2012/04/01/bulk-gps-point-data/
  46. function fetchData(idx) {
  47. if (idx >= CHUNK_COUNT) {
  48. return;
  49. }
  50. // var dataURL = `../../echarts-gl/test/data/gps/gps_${idx}.bin`;
  51. // var dataURL = `../../data-online/gps/gps_${idx}.bin`;
  52. var dataURL = `../../echarts-examples/public/data/asset/data/gps/gps_${idx}.bin`;
  53. var xhr = new XMLHttpRequest();
  54. xhr.open('GET', dataURL, true);
  55. xhr.responseType = 'arraybuffer';
  56. xhr.onload = function (e) {
  57. var rawData = new Int32Array(this.response);
  58. var data = new Float32Array(rawData.length);
  59. var addedDataCount = rawData.length / 2;
  60. for (var i = 0; i < rawData.length; i += 2) {
  61. data[i] = rawData[i+1] / 1e7;
  62. data[i+1] = rawData[i] / 1e7;
  63. }
  64. chart.appendData({
  65. seriesIndex: 0,
  66. data: data
  67. });
  68. var countUp = new CountUp('data-count-number', dataCount, dataCount + addedDataCount, 0, 1);
  69. countUp.start();
  70. dataCount += addedDataCount;
  71. fetchData(idx + 1);
  72. }
  73. xhr.send();
  74. }
  75. chart.setOption({
  76. backgroundColor: '#000',
  77. geo: {
  78. map: 'world',
  79. roam: true,
  80. label: {
  81. emphasis: {
  82. show: false
  83. }
  84. },
  85. silent: true,
  86. itemStyle: {
  87. normal: {
  88. areaColor: '#323c48',
  89. borderColor: '#111'
  90. },
  91. emphasis: {
  92. areaColor: '#2a333d'
  93. }
  94. }
  95. },
  96. series: [{
  97. name: '弱',
  98. type: 'scatter',
  99. progressive: 1e5,
  100. coordinateSystem: 'geo',
  101. symbolSize: 0.5,
  102. blendMode: 'lighter',
  103. large: true,
  104. itemStyle: {
  105. normal: {
  106. color: 'rgb(20, 15, 2)'
  107. }
  108. },
  109. postEffect: {
  110. enable: true
  111. },
  112. silent: true,
  113. dimensions: ['lng', 'lat'],
  114. data: new Float32Array()
  115. }]
  116. });
  117. fetchData(0);
  118. </script>
  119. </body>
  120. </html>