echartsAnimatorCar.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <html>
  5. <head>
  6. <meta charset='utf-8'/>
  7. <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
  8. <title data-i18n="resources.title_animatorCar"></title>
  9. <style>
  10. body {
  11. margin: 0;
  12. padding: 0;
  13. }
  14. #map {
  15. position: absolute;
  16. top: 0;
  17. bottom: 0;
  18. width: 100%;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div id='map'></div>
  24. <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
  25. <script type="text/javascript" include="echarts" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  26. <script type="text/javascript">
  27. var data;
  28. var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  29. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient </a> | </span>" +
  30. "Image <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a> | </span>" +
  31. "<a href='https://echarts.baidu.com' target='_blank'>© 2018 " + " ECharts</a>";
  32. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  33. var tileURL = host + "/iserver/services/map-world/rest/maps/世界地图_Gray/zxyTileImage.png?z={z}&x={x}&y={y}";
  34. var map = new mapboxgl.Map({
  35. container: 'map',
  36. style: {
  37. "version": 8,
  38. "sources": {
  39. "raster-tiles": {
  40. "attribution": attribution,
  41. "type": "raster",
  42. "tiles": [tileURL],
  43. "tileSize": 256,
  44. },
  45. },
  46. "layers": [{
  47. "id": "simple-tiles",
  48. "type": "raster",
  49. "source": "raster-tiles",
  50. "minzoom": 0,
  51. "maxzoom": 22
  52. }]
  53. },
  54. center: [125.33, 43.89],
  55. zoom: 13
  56. });
  57. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  58. var uploadedDataURL = "../data/changchunBus.json";
  59. $.get(uploadedDataURL, function (data) {
  60. var lines = [].concat.apply([], data.map(function (busLine) {
  61. busLine.lineStyle.normal.color = "#000";
  62. busLine.effect = {
  63. constantSpeed: 60,
  64. show: true,
  65. trailLength: 0,
  66. symbolSize: 30,
  67. symbol: function () {
  68. if ((Math.round(Math.random() * 2) % 2)) {
  69. return 'image://../classic/images/blueCar.png'
  70. } else {
  71. return 'image://../classic/images/redCar.png'
  72. }
  73. }()
  74. };
  75. return busLine;
  76. }));
  77. var option = {
  78. animation: false,
  79. GLMap: {
  80. roam: true
  81. },
  82. coordinateSystem: 'GLMap',
  83. geo: {
  84. map: 'GLMap',
  85. },
  86. series: [{
  87. type: 'lines',
  88. polyline: true,
  89. data: lines,
  90. silent: true,
  91. lineStyle: {
  92. normal: {
  93. opacity: 1,
  94. width: 2
  95. }
  96. },
  97. progressiveThreshold: 500,
  98. progressive: 100,
  99. }, {
  100. type: 'lines',
  101. coordinateSystem: 'GLMap',
  102. polyline: true,
  103. data: lines,
  104. lineStyle: {
  105. normal: {
  106. width: 0.2
  107. }
  108. },
  109. effect: {
  110. constantSpeed: 60,
  111. show: true,
  112. trailLength: 0,
  113. symbolSize: 30,
  114. },
  115. }]
  116. };
  117. var echartslayer = new EchartsLayer(map);
  118. echartslayer.chart.setOption(option);
  119. });
  120. </script>
  121. </body>
  122. </html>