echartsAnimatorCar.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_animatorCar"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. </head>
  11. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  12. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  13. <script type="text/javascript" include="echarts" src="../../dist/leaflet/include-leaflet.js"></script>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, url = host + "/iserver/services/map-changchun/rest/maps/长春市区图";
  17. map = L.map('map', {
  18. crs: L.CRS.NonEarthCRS({
  19. bounds: L.bounds([48.4, -7668.25], [8958.85, -55.58]),
  20. origin: L.point(48.4, -55.58)
  21. }),
  22. center: [-3900, 4700],
  23. maxZoom: 18,
  24. zoom: 3
  25. });
  26. L.supermap.tiledMapLayer(url).addTo(map);
  27. queryData();
  28. function queryData() {
  29. var param = new SuperMap.QueryBySQLParameters({
  30. queryParams: {
  31. name: "BusLine@Changchun#1",
  32. attributeFilter: "SmID > 0"
  33. }
  34. });
  35. L.supermap
  36. .queryService(url)
  37. .queryBySQL(param, function (serviceResult) {
  38. addlayers(processData(serviceResult.result.recordsets[0].features.features));
  39. });
  40. function processData(features) {
  41. var busLines = [].concat.apply([], features.map(function (busLine) {
  42. var points = busLine.geometry.coordinates;
  43. return {
  44. coords: points,
  45. effect: {
  46. constantSpeed: 60,
  47. show: true,
  48. trailLength: 0,
  49. symbolSize: 30,
  50. symbol: function () {
  51. if ((Math.round(Math.random() * 2) % 2)) {
  52. return 'image://../classic/images/blueCar.png'
  53. } else {
  54. return 'image://../classic/images/redCar.png'
  55. }
  56. }()
  57. },
  58. };
  59. }));
  60. return busLines;
  61. }
  62. }
  63. function addlayers(busLines) {
  64. var option = {
  65. series: [
  66. {
  67. type: 'lines',
  68. coordinateSystem: 'leaflet',
  69. polyline: true,
  70. data: busLines,
  71. silent: true,
  72. lineStyle: {
  73. normal: {
  74. opacity: 0.2,
  75. width: 2,
  76. color: '#000'
  77. }
  78. },
  79. progressiveThreshold: 500,
  80. progressive: 200,
  81. zlevel: 2
  82. },
  83. {
  84. type: 'lines',
  85. coordinateSystem: 'leaflet',
  86. polyline: true,
  87. data: busLines,
  88. lineStyle: {
  89. normal: {
  90. width: 0
  91. }
  92. },
  93. effect: {
  94. constantSpeed: 60,
  95. show: true,
  96. trailLength: 0,
  97. symbolSize: 30,
  98. },
  99. zlevel: 1
  100. }]
  101. };
  102. L.supermap.echartsLayer(option).addTo(map);
  103. }
  104. </script>
  105. </body>
  106. </html>