echartsGL_GlobalWind.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html lang="en">
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_GlobalWind"></title>
  9. <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
  10. <script type="text/javascript" include="echarts,echarts-gl" src="../../dist/mapboxgl/include-mapboxgl.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>
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map,
  17. mapUrl = host + "/iserver/services/map-china400/rest/maps/ChinaDark/zxyTileImage.png?z={z}&x={x}&y={y}",
  18. attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  19. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  20. "Image <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a> | </span>" +
  21. "<a href='https://echarts.baidu.com' target='_blank'>© 2018 " + resources.title_3baidu +
  22. " ECharts Echarts-gl</a>";
  23. map = new mapboxgl.Map({
  24. container: 'map',
  25. altitudeScale: 2,
  26. style: {
  27. "version": 8,
  28. "sources": {
  29. "raster-tiles": {
  30. "attribution": attribution,
  31. "type": "raster",
  32. "tiles": [mapUrl],
  33. "tileSize": 256
  34. }
  35. },
  36. "layers": [{
  37. "id": "simple-tiles",
  38. "type": "raster",
  39. "source": "raster-tiles",
  40. }]
  41. },
  42. center: [0, 0],
  43. zoom: 1,
  44. });
  45. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  46. map.on('load', function () {
  47. $.getJSON('../data/globalWindData.json', function (windData) {
  48. var data = [];
  49. var p = 0;
  50. var maxMag = 0;
  51. var minMag = Infinity;
  52. for (var j = 0; j < windData.ny; j++) {
  53. for (var i = 0; i < windData.nx; i++, p++) {
  54. var vx = windData.data[p][0];
  55. var vy = windData.data[p][1];
  56. var mag = Math.sqrt(vx * vx + vy * vy);
  57. // 数据是一个一维数组
  58. // [ [经度, 维度,向量经度方向的值,向量维度方向的值] ]
  59. var y = j / windData.ny * 180 - 90;
  60. if (y > 85 || y < -85) {
  61. continue;
  62. }
  63. data.push([
  64. i / windData.nx * 360 - 180,
  65. y,
  66. vx,
  67. vy,
  68. mag
  69. ]);
  70. maxMag = Math.max(mag, maxMag);
  71. minMag = Math.min(mag, minMag);
  72. }
  73. }
  74. var echartslayer = new EchartsLayer(map);
  75. echartslayer.chart.setOption({
  76. GLMap: {
  77. roam: true,
  78. },
  79. geo: {
  80. map: "GLMap"
  81. },
  82. visualMap: {
  83. left: 'right',
  84. min: minMag,
  85. max: maxMag,
  86. dimension: 4,
  87. inRange: {
  88. // color: ['green', 'yellow', 'red']
  89. color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8',
  90. '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027',
  91. '#a50026'
  92. ]
  93. },
  94. realtime: false,
  95. calculable: true,
  96. textStyle: {
  97. color: '#fff'
  98. }
  99. },
  100. series: [{
  101. type: 'flowGL',
  102. coordinateSystem: 'GLMap',
  103. data: data,
  104. particleDensity: 512,
  105. particleSpeed: 2,
  106. particleSize: 1,
  107. gridWidth: 180,
  108. gridHeight: 60,
  109. itemStyle: {
  110. opacity: 0.7
  111. }
  112. }]
  113. });
  114. });
  115. });
  116. </script>
  117. </body>
  118. </html>