mapvPolylineTime.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html lang="en-US">
  6. <head>
  7. <meta charset="UTF-8">
  8. <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  9. <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  10. <title data-i18n="resources.title_mapvPolylineTime"></title>
  11. <style>
  12. body {
  13. margin: 0;
  14. padding: 0;
  15. }
  16. #map {
  17. position: absolute;
  18. top: 0;
  19. bottom: 0;
  20. width: 100%;
  21. }
  22. </style>
  23. </head>
  24. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%">
  25. <div id="map"></div>
  26. <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
  27. <script type="text/javascript" include="mapv,proj4" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  28. <script type="text/javascript">
  29. var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  30. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  31. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a> | </span>" +
  32. "<a href='https://mapv.baidu.com' target='_blank'>© 2018 百度 MapV</a>";
  33. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  34. var tileURL = host + "/iserver/services/map-china400/rest/maps/ChinaDark/zxyTileImage.png?z={z}&x={x}&y={y}";
  35. var map = new mapboxgl.Map({
  36. container: 'map',
  37. style: {
  38. "version": 8,
  39. "sources": {
  40. "raster-tiles": {
  41. "attribution": attribution,
  42. "type": "raster",
  43. "tiles": [tileURL],
  44. "tileSize": 256,
  45. },
  46. },
  47. "layers": [{
  48. "id": "simple-tiles",
  49. "type": "raster",
  50. "source": "raster-tiles",
  51. "minzoom": 0,
  52. "maxzoom": 22
  53. }]
  54. },
  55. center: [114.321317, 30.398428],
  56. zoom: 10
  57. });
  58. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  59. map.addControl(new mapboxgl.supermap.LogoControl(), 'bottom-right');
  60. new mapboxgl.Popup({closeOnClick: false})
  61. .setLngLat(map.getCenter())
  62. .setHTML(resources.text_iClient)
  63. .addTo(map);
  64. $.get('../data/wuhan-car', function (rs) {
  65. var data = [];
  66. var timeData = [];
  67. rs = rs.split("\n");
  68. var maxLength = 0;
  69. for (var i = 0; i < rs.length; i++) {
  70. var item = rs[i].split(',');
  71. var coordinates = [];
  72. if (item.length > maxLength) {
  73. maxLength = item.length;
  74. }
  75. for (j = 0; j < item.length; j += 2) {
  76. if (item.length === 1) {
  77. continue;
  78. }
  79. coordinates.push(proj4('EPSG:3857', 'EPSG:4326', [parseInt(item[j]), parseInt(item[j + 1])]));
  80. timeData.push({
  81. geometry: {
  82. type: 'Point',
  83. coordinates: proj4('EPSG:3857', 'EPSG:4326', [parseInt(item[j]), parseInt(item[j + 1])])
  84. },
  85. count: 1,
  86. time: j
  87. });
  88. }
  89. data.push({
  90. geometry: {
  91. type: 'LineString',
  92. coordinates: coordinates
  93. }
  94. });
  95. }
  96. var dataSet = new mapv.DataSet(data);
  97. var options = {
  98. strokeStyle: 'rgba(53,57,255,0.5)',
  99. coordType: 'bd09mc',
  100. // globalCompositeOperation: 'lighter',
  101. shadowColor: 'rgba(53,57,255,0.2)',
  102. shadowBlur: 3,
  103. lineWidth: 3.0,
  104. draw: 'simple'
  105. };
  106. //mapboxgl.supermap.MapvLayer 构造函数的第一个 map 参数将在下个版本遗弃
  107. var mapVlayer = new mapboxgl.supermap.MapvLayer("", dataSet, options);
  108. map.addLayer(mapVlayer);
  109. var dataSet2 = new mapv.DataSet(timeData);
  110. var options2 = {
  111. fillStyle: 'rgba(255, 250, 250, 0.2)',
  112. coordType: 'bd09mc',
  113. globalCompositeOperation: "lighter",
  114. size: 1.5,
  115. animation: {
  116. stepsRange: {
  117. start: 0,
  118. end: 100
  119. },
  120. trails: 3,
  121. duration: 5,
  122. },
  123. draw: 'simple'
  124. };
  125. //mapboxgl.supermap.MapvLayer 构造函数的第一个 map 参数将在下个版本遗弃
  126. var mapVlayer2 = new mapboxgl.supermap.MapvLayer("", dataSet2, options2);
  127. map.addLayer(mapVlayer2);
  128. });
  129. </script>
  130. </body>
  131. </html>